mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 06:28:53 +00:00
Updated logging and add new user error message after long execution time
This commit is contained in:
1 parent
34c513afdd
commit
846c93558f
1 file changed
+46
-15
@@ -35,18 +35,26 @@ const player = new Player(client);
|
|||||||
|
|
||||||
player.events.on('error', (queue, error) => {
|
player.events.on('error', (queue, error) => {
|
||||||
// Emitted when the player queue encounters error
|
// Emitted when the player queue encounters error
|
||||||
console.log(`General player error event: ${error.message}\n`);
|
console.error(
|
||||||
console.dir(error, { depth: 5 });
|
`${new Date()
|
||||||
console.log(`\nQueue object:`);
|
.toISOString()
|
||||||
console.dir(queue, { depth: 5 });
|
.substring(11, 19)}: Error: 🚨 General player error event: ${
|
||||||
|
error.message
|
||||||
|
}\n`
|
||||||
|
);
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
player.events.on('playerError', (queue, error) => {
|
player.events.on('playerError', (queue, error) => {
|
||||||
// Emitted when the audio player errors while streaming audio track
|
// Emitted when the audio player errors while streaming audio track
|
||||||
console.log(`Player error event: ${error.message}\n`);
|
console.error(
|
||||||
console.dir(error, { depth: 5 });
|
`${new Date()
|
||||||
console.log(`\nQueue object:`);
|
.toISOString()
|
||||||
console.dir(queue, { depth: 5 });
|
.substring(11, 19)}: Error: 🚨 Player error event: ${
|
||||||
|
error.message
|
||||||
|
}\n`
|
||||||
|
);
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.once('ready', async () => {
|
client.once('ready', async () => {
|
||||||
@@ -117,13 +125,36 @@ client.on('interactionCreate', async (interaction) => {
|
|||||||
await command.run({ interaction, client });
|
await command.run({ interaction, client });
|
||||||
const outputTime = new Date();
|
const outputTime = new Date();
|
||||||
const executionTime = outputTime - inputTime;
|
const executionTime = outputTime - inputTime;
|
||||||
console.log(
|
|
||||||
`${new Date().toISOString().substring(11, 19)}: Info: ${
|
if (executionTime > 20000) {
|
||||||
interaction.guild.name
|
console.log(
|
||||||
} (#${
|
`${new Date().toISOString().substring(11, 19)}: Warning: ⚠️ ${
|
||||||
interaction.guild.memberCount
|
interaction.guild.name
|
||||||
})> Command '${interaction}' executed in ${executionTime} ms.`
|
} (#${
|
||||||
);
|
interaction.guild.memberCount
|
||||||
|
})> Command '${interaction}' took ${executionTime} ms to execute.`
|
||||||
|
);
|
||||||
|
|
||||||
|
return await interaction.editReply({
|
||||||
|
embeds: [
|
||||||
|
new EmbedBuilder()
|
||||||
|
.setDescription(
|
||||||
|
`**Warning**\n**This command took ${
|
||||||
|
executionTime / 1000
|
||||||
|
} seconds to execute.**\n\n_If you experienced problems with the command, please try again._`
|
||||||
|
)
|
||||||
|
.setColor(embedColors.colorWarning)
|
||||||
|
]
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
`${new Date().toISOString().substring(11, 19)}: Info: ${
|
||||||
|
interaction.guild.name
|
||||||
|
} (#${
|
||||||
|
interaction.guild.memberCount
|
||||||
|
})> Command '${interaction}' executed in ${executionTime} ms.`
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// log error to console with full object depth
|
// log error to console with full object depth
|
||||||
console.dir(error, { depth: 5 });
|
console.dir(error, { depth: 5 });
|
||||||
|
|||||||
Reference in new issue
Block a user