fix: updated logging for commands

This commit is contained in:
Marius Begby committed 2023-08-26 17:00:08 +02:00
1 parent 5c8f3353f9
commit a04d0aeb5b
24 files changed
+510 -292

No files matched your search

+28 -18
View File
@@ -1,4 +1,3 @@
const logger = require('../../services/logger');
const config = require('config');
const embedOptions = config.get('embedOptions');
const playerOptions = config.get('playerOptions');
@@ -16,6 +15,15 @@ module.exports = {
.setNSFW(false)
.addNumberOption((option) => option.setName('page').setDescription('Page number of the queue').setMinValue(1)),
execute: async ({ interaction, executionId }) => {
const logger = require('../../services/logger').child({
source: 'queue.js',
module: 'slashCommand',
name: '/queue',
executionId: executionId,
shardId: interaction.guild.shardId,
guildId: interaction.guild.id
});
if (await notInVoiceChannel({ interaction, executionId })) {
return;
}
@@ -31,9 +39,9 @@ module.exports = {
if (!queue) {
if (pageIndex >= 1) {
logger.debug(
`User used command ${interaction.commandName} but there was no queue.`
);
logger.debug(`There is no queue and user tried to access page ${pageIndex + 1}.`);
logger.debug('Responding with warning embed.');
return await interaction.editReply({
embeds: [
new EmbedBuilder()
@@ -47,10 +55,10 @@ module.exports = {
});
}
logger.debug(
`User used command ${interaction.commandName} but there was no queue.`
);
logger.debug('There is no queue, displaying empty queue.');
queueString = 'The queue is empty, add some tracks with **`/play`**!';
logger.debug('Responding with info embed.');
return await interaction.editReply({
embeds: [
new EmbedBuilder()
@@ -71,10 +79,9 @@ module.exports = {
const totalPages = Math.ceil(queueLength / 10) || 1;
if (pageIndex > totalPages - 1) {
logger.debug(
`User used command ${interaction.commandName} but page was higher than total pages.`
);
logger.debug('Specified page was higher than total pages.');
logger.debug('Responding with warning embed.');
return await interaction.editReply({
embeds: [
new EmbedBuilder()
@@ -89,6 +96,7 @@ module.exports = {
}
if (queue.tracks.data.length === 0) {
logger.debug('Queue exists but with no tracks, displaying empty queue.');
queueString = 'The queue is empty, add some tracks with **`/play`**!';
} else {
queueString = queue.tracks.data
@@ -101,7 +109,9 @@ module.exports = {
durationFormat = `${embedOptions.icons.liveTrack} \`LIVE\``;
}
return `**${pageIndex * 10 + index + 1}.** **${durationFormat} [${track.title}](${track.url})**`;
return `**${pageIndex * 10 + index + 1}.** **${durationFormat} [${track.title}](${
track.raw.url ?? track.url
})**`;
})
.join('\n');
}
@@ -126,10 +136,9 @@ module.exports = {
}`;
if (!currentTrack) {
logger.debug(
`User used command ${interaction.commandName} but there was no current track.`
);
logger.debug('Queue exists but there is no current track.');
logger.debug('Responding with info embed.');
return await interaction.editReply({
embeds: [
new EmbedBuilder()
@@ -147,6 +156,7 @@ module.exports = {
]
});
} else {
logger.debug('Queue exists with current track, gathering information.');
const timestamp = queue.node.getTimestamp();
let bar = `**\`${timestamp.current.label}\`** ${queue.node.createProgressBar({
queue: false,
@@ -165,9 +175,7 @@ module.exports = {
bar = `${embedOptions.icons.liveTrack} **\`LIVE\`** - Playing continuously from live source.`;
}
logger.debug(
`User used command ${interaction.commandName} and got queue in reply with current track.`
);
logger.debug('Responding with info embed.');
return await interaction.editReply({
embeds: [
new EmbedBuilder()
@@ -177,7 +185,9 @@ module.exports = {
})
.setDescription(
`**${embedOptions.icons.audioPlaying} Now playing**\n` +
(currentTrack ? `**[${currentTrack.title}](${currentTrack.url})**` : 'None') +
(currentTrack
? `**[${currentTrack.title}](${currentTrack.raw.url ?? currentTrack.url})**`
: 'None') +
`\nRequested by: <@${currentTrack.requestedBy.id}>` +
`\n ${bar}\n\n` +
`${repeatModeString}` +