From 623f4e200fbf33613370c974b6c483748fd96cce Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Mon, 21 Aug 2023 19:53:55 +0200 Subject: [PATCH 1/3] fix: Fix bug in /shards when shard count is 1 on shown page --- src/commands/system/shards.js | 36 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/commands/system/shards.js b/src/commands/system/shards.js index 6ca61b4..bf83bde 100644 --- a/src/commands/system/shards.js +++ b/src/commands/system/shards.js @@ -81,22 +81,34 @@ module.exports = { const evenShardIndexesString = evenShardIndexes.map(shardInfoToString).join('\n') + 'ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ'; const oddShardIndexesString = oddShardIndexes.map(shardInfoToString).join('\n'); + const embedFields = []; + + if (currentPageShards.length === 1) { + embedFields.push({ + name: ' ', + value: currentPageShards.map(shardInfoToString).join('\n'), + inline: false + }); + } else { + embedFields.push( + { + name: ' ', + value: evenShardIndexesString, + inline: true + }, + { + name: ' ', + value: oddShardIndexesString, + inline: true + } + ); + } + return await interaction.editReply({ embeds: [ new EmbedBuilder() .setDescription(`**${embedOptions.icons.server} Shard overview - ${shardCount} total shards**\n`) - .addFields( - { - name: ' ', - value: evenShardIndexesString, - inline: true - }, - { - name: ' ', - value: oddShardIndexesString, - inline: true - } - ) + .addFields(...embedFields) .setColor(embedOptions.colors.info) .setFooter({ text: `Shard id: ${client.shard.ids[0]}, page ${pageIndex + 1} of ${totalPages}` }) ] From 94ef202c7f8443a40bf813247950fa6867d97bb3 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Mon, 21 Aug 2023 20:32:32 +0200 Subject: [PATCH 2/3] fix: handle message component interactions logging --- src/events/interactions/interactionCreate.js | 28 +++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/events/interactions/interactionCreate.js b/src/events/interactions/interactionCreate.js index abd3dd1..fc34d61 100644 --- a/src/events/interactions/interactionCreate.js +++ b/src/events/interactions/interactionCreate.js @@ -9,16 +9,27 @@ module.exports = { name: Events.InteractionCreate, isDebug: false, execute: async (interaction, { client }) => { + if (interaction.isMessageComponent()) { + logger.info( + `[Shard ${interaction.guild.shardId}] Guild ${ + interaction.guild.id + }> Message component interaction created for id ${interaction.customId}${ + interaction.values ? ' and values ' + interaction.values : '' + }.` + ); + return; + } + const command = client.commands.get(interaction.commandName); if (!command) { logger.warn( - `[Shard ${interaction.guild.shardId}] Interaction created but command '${interaction.commandName}' was not found.` + `[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction created but command '${interaction.commandName}' was not found.` ); return; } if (interaction.isAutocomplete()) { - logger.debug(`[Shard ${interaction.guild.shardId}] Autocomplete created.`); + logger.debug(`[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Autocomplete created.`); try { await command.autocomplete({ interaction, client }); } catch (error) { @@ -27,7 +38,7 @@ module.exports = { error.message === 'Interaction has already been acknowledged.' ) { logger.debug( - `[Shard ${interaction.guild.shardId}] Autocomplete failed to be responded to, unknown interaction or already acknowledged.` + `[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Autocomplete failed to be responded to, unknown interaction or already acknowledged.` ); return; } else { @@ -36,11 +47,10 @@ module.exports = { return; } } else if (interaction.isChatInputCommand()) { - logger.debug(`[Shard ${interaction.guild.shardId}] Interaction created.`); + logger.debug(`[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction created.`); try { await interaction.deferReply(); - // causing issues with unknown interaction error? if (await cannotSendMessageInChannel(interaction)) { return; } @@ -62,7 +72,7 @@ module.exports = { if (!interaction.deferred || !interaction.replied) { logger.warn( - `[Shard ${interaction.guild.shardId}] Interaction was not deferred or replied to, and an error was thrown.` + `[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction was not deferred or replied to, and an error was thrown.` ); return; } @@ -72,7 +82,7 @@ module.exports = { return; } else if (interaction.deferred) { logger.info( - `[Shard ${interaction.guild.shardId}] Interaction was deferred, editing reply and sending Uh-oh message.` + `[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction was deferred, editing reply and sending Uh-oh message.` ); await interaction.editReply({ embeds: [ @@ -85,7 +95,7 @@ module.exports = { }); } else { logger.info( - `[Shard ${interaction.guild.shardId}] Interaction was not deferred or replied, sending new reply with Uh-oh message.` + `[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction was not deferred or replied, sending new reply with Uh-oh message.` ); await interaction.reply({ embeds: [ @@ -101,7 +111,7 @@ module.exports = { } else { logger.warn( interaction, - `[Shard ${interaction.guild.shardId}] Interaction created but was not a chat input or autocomplete interaction.` + `[Shard ${interaction.guild.shardId}] Guild ${interaction.guild.id}> Interaction created but was not a chat input or autocomplete interaction.` ); } } From bd249e686701f3473a2c5c24eba5a996d7c1732d Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Mon, 21 Aug 2023 21:34:29 +0200 Subject: [PATCH 3/3] fix: handle no queue dispatcher error when /queue and bot not in vc --- src/utils/validation/voiceChannelValidator.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/validation/voiceChannelValidator.js b/src/utils/validation/voiceChannelValidator.js index e2585ac..df83238 100644 --- a/src/utils/validation/voiceChannelValidator.js +++ b/src/utils/validation/voiceChannelValidator.js @@ -23,8 +23,9 @@ exports.notInVoiceChannel = async (interaction) => { }; exports.notInSameVoiceChannel = async (interaction, queue) => { - if (!queue.dispatcher) { - return true; + if (!queue || !queue.dispatcher) { + // If there is no queue or bot is not in voice channel, then there is no need to check if user is in same voice channel. + return false; } if (interaction.member.voice.channel.id !== queue.dispatcher.channel.id) {