diff --git a/.env.example b/.env.example index 76fa0888..99ef9cd5 100644 --- a/.env.example +++ b/.env.example @@ -9,6 +9,7 @@ XIAO_WEBHOOK_ID= XIAO_WEBHOOK_TOKEN= REPORT_CHANNEL_ID= JOIN_LEAVE_CHANNEL_ID= +COMMAND_CHANNEL_ID= # Events APRIL_FOOLS= diff --git a/Xiao.js b/Xiao.js index 2202aa27..b56d7303 100644 --- a/Xiao.js +++ b/Xiao.js @@ -356,11 +356,15 @@ client.on('error', err => client.logger.error(err.stack)); client.on('warn', warn => client.logger.warn(warn)); -client.on('commandRun', command => { +client.on('commandRun', async command => { + client.logger.info(`[COMMAND] ${command.name} was used.`); if (command.uses === undefined) return; command.uses++; if (command.lastRun === undefined) return; command.lastRun = new Date(); + const channel = await client.fetchCommandChannel(); + channel.send(`\`${command.name}\` was used! It has now been used **${formatNumber(command.uses)}** times!`) + .catch(() => null); }); client.dispatcher.addInhibitor(msg => { diff --git a/structures/Client.js b/structures/Client.js index 7372d182..8ce5643c 100644 --- a/structures/Client.js +++ b/structures/Client.js @@ -21,6 +21,7 @@ const { XIAO_WEBHOOK_TOKEN, REPORT_CHANNEL_ID, JOIN_LEAVE_CHANNEL_ID, + COMMAND_CHANNEL_ID, TOP_GG_TOKEN, BOTS_GG_TOKEN, DISCORDBOTLIST_TOKEN, @@ -283,4 +284,9 @@ module.exports = class XiaoClient extends CommandoClient { if (!JOIN_LEAVE_CHANNEL_ID) return null; return this.channels.fetch(JOIN_LEAVE_CHANNEL_ID); } + + fetchCommandChannel() { + if (!COMMAND_CHANNEL_ID) return null; + return this.channels.fetch(COMMAND_CHANNEL_ID); + } };