diff --git a/commands/end.js b/commands/end.js index 724a7e0..61dfa71 100644 --- a/commands/end.js +++ b/commands/end.js @@ -8,14 +8,14 @@ module.exports = { trusted: 1, execute: function(bot, username, usernameraw, sender, prefix, args) { if (args[0]===bot.hash) { - bot.emit('end', 'end command'); + bot.end('end command'); } else { throw new Error('Invalid hash'); } }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { if (message.member._roles.at(0)===config.discord.trustedRoleID) { - bot.emit('end', 'end command'); + bot.end('end command'); } else { throw new Error('You\'re not in trusted role!'); } diff --git a/index.js b/index.js index fb192ca..d7dc2fc 100644 --- a/index.js +++ b/index.js @@ -372,13 +372,15 @@ function main() { }); process.on('SIGINT', async function() { - bot.chat('Interrupted by console'); + try { + bot.chat('Interrupted by console'); + } catch (e) { + return; + } process.exit(); }); -} -function onEnd() { - bot.on('end', (reason, event) => { + bot.once('end', (reason, event) => { console.log(`Disconnected (${event} event): ${util.inspect(reason)}`); channel.send(`Disconnected (${event} event): ${util.inspect(reason)}`); @@ -433,7 +435,6 @@ dcclient.on('ready', async () => { } await sleep(200); main(); - onEnd(); chomenschannel = dcclient.channels.cache.get(chomenschannel); bot.hashchannel = dcclient.channels.cache.get(hashchannel); bot.ownerhashchannel = dcclient.channels.cache.get(ownerhashchannel);