Better logging for command execution time

This commit is contained in:
Marius Begby committed 2023-07-07 22:19:20 +02:00
1 parent 9f5dd47954
commit 217e2f1c2a
1 file changed
+5 -2
+5 -2
View File
@@ -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