From 217e2f1c2a4bab3de92b37c3497b6f4c06229156 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Fri, 7 Jul 2023 22:19:20 +0200 Subject: [PATCH] Better logging for command execution time --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c46e9ee..cb08af3 100644 --- a/index.js +++ b/index.js @@ -101,14 +101,17 @@ client.on('interactionCreate', async (interaction) => { if (!command) return; try { + const inputTime = new Date(); await interaction.deferReply(); await command.run({ interaction, client }); + const outputTime = new Date(); + const executionTime = outputTime - inputTime; console.log( `${new Date().toISOString().substring(11, 19)}: ${ interaction.guild.name - } (#${interaction.guild.memberCount})> Command '/${ + } (#${interaction.guild.memberCount})> Ran command '/${ interaction.commandName - }' was executed successfully.` + }' successfully in ${executionTime} ms.` ); } catch (error) { // log error to console with full object depth