mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 06:42:51 +02:00
Log every command
This commit is contained in:
@@ -9,6 +9,7 @@ XIAO_WEBHOOK_ID=
|
|||||||
XIAO_WEBHOOK_TOKEN=
|
XIAO_WEBHOOK_TOKEN=
|
||||||
REPORT_CHANNEL_ID=
|
REPORT_CHANNEL_ID=
|
||||||
JOIN_LEAVE_CHANNEL_ID=
|
JOIN_LEAVE_CHANNEL_ID=
|
||||||
|
COMMAND_CHANNEL_ID=
|
||||||
|
|
||||||
# Events
|
# Events
|
||||||
APRIL_FOOLS=
|
APRIL_FOOLS=
|
||||||
|
|||||||
@@ -356,11 +356,15 @@ client.on('error', err => client.logger.error(err.stack));
|
|||||||
|
|
||||||
client.on('warn', warn => client.logger.warn(warn));
|
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;
|
if (command.uses === undefined) return;
|
||||||
command.uses++;
|
command.uses++;
|
||||||
if (command.lastRun === undefined) return;
|
if (command.lastRun === undefined) return;
|
||||||
command.lastRun = new Date();
|
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 => {
|
client.dispatcher.addInhibitor(msg => {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const {
|
|||||||
XIAO_WEBHOOK_TOKEN,
|
XIAO_WEBHOOK_TOKEN,
|
||||||
REPORT_CHANNEL_ID,
|
REPORT_CHANNEL_ID,
|
||||||
JOIN_LEAVE_CHANNEL_ID,
|
JOIN_LEAVE_CHANNEL_ID,
|
||||||
|
COMMAND_CHANNEL_ID,
|
||||||
TOP_GG_TOKEN,
|
TOP_GG_TOKEN,
|
||||||
BOTS_GG_TOKEN,
|
BOTS_GG_TOKEN,
|
||||||
DISCORDBOTLIST_TOKEN,
|
DISCORDBOTLIST_TOKEN,
|
||||||
@@ -283,4 +284,9 @@ module.exports = class XiaoClient extends CommandoClient {
|
|||||||
if (!JOIN_LEAVE_CHANNEL_ID) return null;
|
if (!JOIN_LEAVE_CHANNEL_ID) return null;
|
||||||
return this.channels.fetch(JOIN_LEAVE_CHANNEL_ID);
|
return this.channels.fetch(JOIN_LEAVE_CHANNEL_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchCommandChannel() {
|
||||||
|
if (!COMMAND_CHANNEL_ID) return null;
|
||||||
|
return this.channels.fetch(COMMAND_CHANNEL_ID);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user