diff --git a/index.js b/index.js index 629e7e5..f8039cf 100644 --- a/index.js +++ b/index.js @@ -22,4 +22,22 @@ async function runModules() { await require(`./util/${file}`).run(); } } -runModules(); \ No newline at end of file +runModules(); + + +// Destroy client when SIGINT +process.on('SIGINT', async () => { + process.stdin.resume(); // Don't exit immediately + + console.log(''); + logger.info('SIGINT received.'); + + try { + await client.destroy(); + } catch(e) { + logger.warn('Failed to destroy client'); + } + + logger.done('Logged out client, exiting.'); + process.exit(); +}); \ No newline at end of file