diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..9868145 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +worker: npm run start:prod \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0159946..c58364b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sf-discord-bot", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 77b7341..3eb7cbd 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "sf-discord-bot", - "version": "0.1.0", + "version": "0.2.0", "description": "A discord bot for Shakes and Fidget.", - "main": "src/index.js", + "main": "src/bot.js", "scripts": { - "start": "node .", + "start": "NODE_ENV=development node .", + "start:prod": "NODE_ENV=production node .", "lint": "eslint .", "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/src/index.js b/src/bot.js similarity index 81% rename from src/index.js rename to src/bot.js index 093cbcc..25ddf6d 100644 --- a/src/index.js +++ b/src/bot.js @@ -45,9 +45,14 @@ client.on('message', message => { }); client.on('guildMemberAdd', member => { - const channel = client.channels.cache.get(welcome_channel_id); - if (!channel) return; - channel.send(`Welcome ${member} to our Server. If you want my help call me with ${prefix}help.`); + const channel = client.channels.cache.get(welcome_channel_id); + if (!channel) return; + channel.send(`Welcome ${member} to our Server. If you want my help call me with ${prefix}help.`); }); -client.login(token); +// In production mode read the token from env +if (process.env.NODE_ENV === 'production') { + client.login(process.env.BOT_TOKEN); +} else { + client.login(token); +}