diff --git a/commands/kill.js b/commands/kill.js new file mode 100644 index 0000000..c124080 --- /dev/null +++ b/commands/kill.js @@ -0,0 +1,24 @@ +const ownerID = process.env.ownerID; + +module.exports = { + name: 'kill', + description: 'Kills the bot OWNER ONLY', + execute(message, args) { + if (message.author.id == ownerID) { + message.channel.send('Shutting down the bot...') + .then(() => { + message.client.destroy(); + process.exit(); + }); + } else { + message.reply('Sorry, only the owner can do that.'); + message.client.users.fetch(ownerID) + .then(user => { + user.send(message.author.username + ' attempted to shutdown the bot.') + .then() + .catch(err => console.error(err)); + }) + .catch(err => console.error(err)); + } + } +} \ No newline at end of file diff --git a/config.json b/config.json index 7b3bac1..dc0cec2 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,7 @@ { "prefix": "/", - "serverID": "760701839427108874" + "serverID": "760701839427108874", + "logChannel": "858449941911437353", + "bootMessage": "NodBot v2 Starting Up", + "shutdownMessage": "NodBot v2 Shutting Down" } \ No newline at end of file diff --git a/index.js b/index.js index 03f1ebc..2075af9 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ const client = new Discord.Client(); const debug = true; // const config = require('./config.json'); -const { prefix } = require('./config.json'); +const { prefix, logChannel, bootMessage, shutdownMessage } = require('./config.json'); // const owner = process.env.ownerID; const giphy = require('giphy-api')(process.env.giphyAPIKey); @@ -20,6 +20,13 @@ client.once('ready', () => { functions.getCommandFiles(client); functions.getGifFiles(client); functions.getPastaFiles(client); + client.channels.fetch(logChannel) + .then(channel => { + channel.send(bootMessage) + .then() + .catch(err => console.error(err)); + }) + .catch(err => console.error(err)); }); client.login(process.env.TOKEN); @@ -77,7 +84,7 @@ client.on('message', message => { if (!client.pastas.has(file[0])) { message.reply('Sorry I couldn\'t find that gif.'); } else { - message.channel.send(client.pastas.get(file[0]).content); + message.channel.send(client.pastas.get(file[0]).content, { split: { char: ' ' } }); } break; default: