diff --git a/src/commands/player/play.js b/src/commands/player/play.js index 4d2ea6d6..1a55b8e2 100644 --- a/src/commands/player/play.js +++ b/src/commands/player/play.js @@ -102,6 +102,23 @@ module.exports = { }); } + let queue = useQueue(interaction.guild.id); + let queueSize = queue?.size ?? 0; + + if ((searchResult.playlist && searchResult.tracks.length) > playerOptions.maxQueueSize - queueSize) { + logger.debug(`[Shard ${interaction.guild.shardId}] Playlist found but too many tracks. Query: ${query}.`); + + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setDescription( + `**${embedOptions.icons.warning} Playlist too large**\nThis playlist is too large to be added to the queue.\n\nThe maximum amount of tracks that can be added to the queue is **${playerOptions.maxQueueSize}**.` + ) + .setColor(embedOptions.colors.warning) + ] + }); + } + let track; try { @@ -202,7 +219,7 @@ module.exports = { ); } - let queue = useQueue(interaction.guild.id); + queue = useQueue(interaction.guild.id); if (!queue) { logger.warn( diff --git a/src/config_example.js b/src/config_example.js index 87c1b6d1..75e190f7 100644 --- a/src/config_example.js +++ b/src/config_example.js @@ -110,7 +110,7 @@ module.exports.playerOptions = { leaveOnStop: true, leaveOnStopCooldown: 300_000, defaultVolume: 50, - maxQueueSize: 1_000, + maxQueueSize: 10_000, maxHistorySize: 100, bufferingTimeout: 3_000, connectionTimeout: 30_000, diff --git a/src/events/interactions/interactionCreate.js b/src/events/interactions/interactionCreate.js index 80b70be5..dc32561f 100644 --- a/src/events/interactions/interactionCreate.js +++ b/src/events/interactions/interactionCreate.js @@ -23,6 +23,12 @@ module.exports = { try { await command.autocomplete({ interaction, client }); } catch (error) { + if (error.message === 'Unknown interaction') { + logger.debug( + `[Shard ${interaction.guild.shardId}] Autocomplete failed to be responded to, providing a response took too long.` + ); + return; + } logger.warn(error, `[Shard ${interaction.guild.shardId}] Autocomplete failed to execute.`); return; }