fix: updated logging for validators

This commit is contained in:
Marius Begby committed 2023-08-26 14:39:33 +02:00
1 parent 22109823e1
commit 57fc1e3ee8
23 files changed
+118 -70

No files matched your search

+33 -10
View File
@@ -1,9 +1,17 @@
const logger = require('../../services/logger');
const config = require('config');
const embedOptions = config.get('embedOptions');
const { EmbedBuilder } = require('discord.js');
exports.queueDoesNotExist = async (interaction, queue) => {
exports.queueDoesNotExist = async ({ interaction, queue, executionId }) => {
const logger = require('../../services/logger').child({
source: 'queueValidator.js',
module: 'validator',
name: 'queueDoesNotExist',
executionId: executionId,
shardId: interaction.guild.shardId,
guildId: interaction.guild.id
});
if (!queue) {
await interaction.editReply({
embeds: [
@@ -15,15 +23,23 @@ exports.queueDoesNotExist = async (interaction, queue) => {
]
});
logger.debug(`User tried to use command ${interaction.commandName} but there was no queue.`);
logger.debug(`User tried to use command '${interaction.commandName}' but there was no queue.`);
return true;
}
return false;
};
exports.queueNoCurrentTrack = async (interaction, queue) => {
exports.queueNoCurrentTrack = async ({ interaction, queue, executionId }) => {
const logger = require('../../services/logger').child({
source: 'queueValidator.js',
module: 'validator',
name: 'queueNoCurrentTrack',
executionId: executionId,
shardId: interaction.guild.shardId,
guildId: interaction.guild.id
});
if (!queue.currentTrack) {
await interaction.editReply({
embeds: [
@@ -35,15 +51,23 @@ exports.queueNoCurrentTrack = async (interaction, queue) => {
]
});
logger.debug(`User tried to use command ${interaction.commandName} but there was no current track.`);
logger.debug(`User tried to use command '${interaction.commandName}' but there was no current track.`);
return true;
}
return false;
};
exports.queueIsEmpty = async (interaction, queue) => {
exports.queueIsEmpty = async ({ interaction, queue, executionId }) => {
const logger = require('../../services/logger').child({
source: 'queueValidator.js',
module: 'validator',
name: 'queueIsEmpty',
executionId: executionId,
shardId: interaction.guild.shardId,
guildId: interaction.guild.id
});
if (queue.tracks.data.length === 0) {
await interaction.editReply({
embeds: [
@@ -55,8 +79,7 @@ exports.queueIsEmpty = async (interaction, queue) => {
]
});
logger.debug(`User tried to use command ${interaction.commandName} but there was no tracks in the queue.`);
logger.debug(`User tried to use command '${interaction.commandName}' but there was no tracks in the queue.`);
return true;
}