From cb411ed813a81ed2943573c27a369f1d570c3c1a Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 27 Feb 2019 18:22:16 +0100 Subject: [PATCH] Tell the remaining cooldown for the command --- event/listeners/cooldown.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 event/listeners/cooldown.js diff --git a/event/listeners/cooldown.js b/event/listeners/cooldown.js new file mode 100644 index 00000000..a3073b21 --- /dev/null +++ b/event/listeners/cooldown.js @@ -0,0 +1,26 @@ +const { Listener } = require('discord-akairo'); + +class cooldownListener extends Listener { + constructor() { + super('cooldown', { + emitter: 'commandHandler', + event: 'cooldown' + }); + } + + async exec(message, command, number) { + let seconds = parseInt((number / 1000) % 60), + minutes = parseInt((number / (1000 * 60)) % 60), + hours = parseInt((number / (1000 * 60 * 60)) % 24); + + hours = (hours < 10) ? '0' + hours : hours; + minutes = (minutes < 10) ? '0' + minutes : minutes; + seconds = (seconds < 10) ? '0' + seconds : seconds; + + let time = hours + ':' + minutes + ':' + seconds; + + message.reply(`You can use the \`${command.id}\` command in \`${time}\``); + } +} + +module.exports = cooldownListener; \ No newline at end of file