Show execution time

This commit is contained in:
loicbersier 2020-05-03 22:41:54 +02:00
parent 8af6023267
commit 7f0453b3a5
2 changed files with 20 additions and 2 deletions

View file

@ -0,0 +1,16 @@
const { Listener } = require('discord-akairo');
class commandFinishedListener extends Listener {
constructor() {
super('commandFinished', {
emitter: 'commandHandler',
event: 'commandFinished'
});
}
async exec(message, command) {
console.timeEnd(command.id);
}
}
module.exports = commandFinishedListener;

View file

@ -13,6 +13,8 @@ class commandStartedListener extends Listener {
} }
async exec(message, command) { async exec(message, command) {
console.time(command.id);
//This is for april fools //This is for april fools
let today = new Date(), lastUpdate; let today = new Date(), lastUpdate;
@ -27,7 +29,7 @@ class commandStartedListener extends Listener {
} }
let curDate = dd + '.' + mm; let curDate = dd + '.' + mm;
//Only execute when its april first //Only execute when its april first
if (curDate == '01.04' && !serverID.includes(message.guild.id)) { if (curDate === '01.04' && !serverID.includes(message.guild.id)) {
let count = Math.random() * 100; let count = Math.random() * 100;
if (count < 10) { if (count < 10) {
serverID.push(message.guild.id); serverID.push(message.guild.id);
@ -49,7 +51,7 @@ class commandStartedListener extends Listener {
} }
if (dailyStats) { if (dailyStats) {
if (command.category.id == 'owner') return; // Don't count owner command if (command.category.id === 'owner') return; // Don't count owner command
let obj = { let obj = {
guild: message.guild.id, guild: message.guild.id,
command: command.id command: command.id