From 7f0453b3a55cc35c3c4ce9492fb2ac68452130df Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 3 May 2020 22:41:54 +0200 Subject: [PATCH] Show execution time --- event/listeners/commandfinish.js | 16 ++++++++++++++++ event/listeners/commandstarted.js | 6 ++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 event/listeners/commandfinish.js diff --git a/event/listeners/commandfinish.js b/event/listeners/commandfinish.js new file mode 100644 index 00000000..0b9cbeb2 --- /dev/null +++ b/event/listeners/commandfinish.js @@ -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; \ No newline at end of file diff --git a/event/listeners/commandstarted.js b/event/listeners/commandstarted.js index 380eddc7..36736fbc 100644 --- a/event/listeners/commandstarted.js +++ b/event/listeners/commandstarted.js @@ -13,6 +13,8 @@ class commandStartedListener extends Listener { } async exec(message, command) { + console.time(command.id); + //This is for april fools let today = new Date(), lastUpdate; @@ -27,7 +29,7 @@ class commandStartedListener extends Listener { } let curDate = dd + '.' + mm; //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; if (count < 10) { serverID.push(message.guild.id); @@ -49,7 +51,7 @@ class commandStartedListener extends Listener { } 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 = { guild: message.guild.id, command: command.id