Skip to content

Commit

Permalink
Added a Heroku button for easy deploy. (#13)
Browse files Browse the repository at this point in the history
* Added heroku files.

* Added support for heroku env variables.

* Updated README.
  • Loading branch information
moonstar-x authored Sep 24, 2019
1 parent bcefbe4 commit bad9ea5
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ node_modules/
config/settings.json

# Old files
*.old
*.old

# Env files
*.env
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bot: npm start
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ You can now run your bot:

npm start

### Deploying to Heroku

To deploy to Heroku, you can click on the image below and login to your account.

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/moonstar-x/discord-tts-bot)

You can now go back to your app's *Overview*, make sure you disable the *web* dyno and enable the *bot* dyno. Your bot should now be up and running. Remember you can always check your bot's console if you access the *View Logs* in the *More* dropdown menu.

## Usage

Here's a list of all the commands for the bot:
Expand Down
22 changes: 22 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Discord Text-to-Speech Bot",
"description": "A small Discord bot sends Text-to-Speech messages in various languages.",
"repository": "https://github.com/moonstar-x/discord-tts-bot",
"logo": "https://i.imgur.com/Tqnk48j.png",
"env": {
"PREFIX": {
"description": "Your bot's command prefix.",
"value": "$",
"required": true
},
"DISCORD_TOKEN": {
"description": "Your bot's bot token.",
"required": true
},
"ALLOW_OVER_200": {
"description": "Type 'yes' if you wish to send TTS messages of over 200 characters long.",
"required": true,
"value": "yes"
}
}
}
4 changes: 2 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { Client, Collection, Structures } = require('discord.js');
const fs = require('fs-extra');
const path = require('path');
const config = require('../config/settings.json');
const discordToken = process.env.DISCORD_TOKEN || require('../config/settings.json').discord_token;
const appEvents = require('./events/appEvents');
const appHandlers = require('./events/handlers/app');
const { TTSGuild } = require('./classes/extensions');
Expand Down Expand Up @@ -30,4 +30,4 @@ if (process.argv[2] === '--debug') {
client.on(appEvents.debug, (info) => appHandlers.debug(info));
}

client.login(config.discord_token);
client.login(discordToken);
2 changes: 1 addition & 1 deletion src/classes/TTSPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const googleTTS = require('google-tts-api');
const { Logger } = require('logger');
const dispatcherEvents = require('../events/dispatcherEvents');
const languages = require('../../data/languages.json');
const { prefix } = require('../../config/settings.json');
const prefix = process.env.PREFIX || require('../../config/settings.json').prefix;

const logger = new Logger();

Expand Down
2 changes: 1 addition & 1 deletion src/commands/help.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { MessageEmbed } = require('discord.js');
const { MESSAGE_EMBED } = require('../common/constants');
const { prefix } = require('../../config/settings.json');
const prefix = process.env.PREFIX || require('../../config/settings.json').prefix;

module.exports = {
name: 'help',
Expand Down
2 changes: 1 addition & 1 deletion src/commands/lang.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { prefix } = require('../../config/settings.json');
const prefix = process.env.PREFIX || require('../../config/settings.json').prefix;
const languages = require('../../data/languages.json');

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/speed.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { prefix } = require('../../config/settings.json');
const prefix = process.env.PREFIX || require('../../config/settings.json').prefix;

module.exports = {
name: 'speed',
Expand Down
2 changes: 1 addition & 1 deletion src/common/langsEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { MessageEmbed } = require('discord.js');
const { MESSAGE_EMBED } = require('./constants');
const { prefix } = require('../../config/settings.json');
const prefix = process.env.PREFIX || require('../../config/settings.json').prefix;

const embed = new MessageEmbed()
.setTitle('List of supported languages:')
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Logger } = require('logger');
const { ACTIVITY_TYPE, TTS_MAX_CHARS } = require('./constants');
const { allow_more_than_200_chars: allowOver200 } = require('../../config/settings.json');
const allowOver200 = process.env.ALLOW_OVER_200 || require('../../config/settings.json').allow_more_than_200_chars;

const logger = new Logger();

Expand Down
2 changes: 1 addition & 1 deletion src/events/handlers/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Logger } = require('logger');
const TTSPlayer = require('../../classes/TTSPlayer');
const { prefix } = require('../../../config/settings.json');
const prefix = process.env.PREFIX || require('../../../config/settings.json').prefix;
const { updatePresence, executeCommand } = require('../../common/utils');

const logger = new Logger();
Expand Down

0 comments on commit bad9ea5

Please sign in to comment.