feat: added /stop command

This commit is contained in:
Marius Begby committed 2023-07-23 12:26:26 +02:00
1 parent 52f1dd2dea
commit 3c52841cd6
4 files changed
+78 -20

No files matched your search

+14 -14
View File
@@ -38,20 +38,20 @@ module.exports = {
logger.debug( logger.debug(
`[Shard ${interaction.guild.shardId}] User used command ${interaction.commandName} and deleted the queue.` `[Shard ${interaction.guild.shardId}] User used command ${interaction.commandName} and deleted the queue.`
); );
return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setAuthor({
name: interaction.member.nickname || interaction.user.username,
iconURL: interaction.user.avatarURL()
})
.setDescription(
`**${embedOptions.icons.success} Leaving channel**\nCleared the track queue and left voice channel.\n\nTo play more music, use the **\`/play\`** command!`
)
.setColor(embedOptions.colors.success)
]
});
} }
return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setAuthor({
name: interaction.member.nickname || interaction.user.username,
iconURL: interaction.user.avatarURL()
})
.setDescription(
`**${embedOptions.icons.success} Leaving channel**\nCleared the track queue and left voice channel.\n\nTo play more music, use the **\`/play\`** command!`
)
.setColor(embedOptions.colors.success)
]
});
} }
}; };
+3 -3
View File
@@ -78,11 +78,11 @@ module.exports = {
requestedBy: interaction.user, requestedBy: interaction.user,
nodeOptions: { nodeOptions: {
leaveOnEmpty: playerOptions.leaveOnEmpty ?? true, leaveOnEmpty: playerOptions.leaveOnEmpty ?? true,
leaveOnEmptyCooldown: playerOptions.leaveOnEmptyCooldown ?? 60000, leaveOnEmptyCooldown: playerOptions.leaveOnEmptyCooldown ?? 300_000,
leaveOnEnd: playerOptions.leaveOnEnd ?? true, leaveOnEnd: playerOptions.leaveOnEnd ?? true,
leaveOnEndCooldown: playerOptions.leaveOnEndCooldown ?? 60000, leaveOnEndCooldown: playerOptions.leaveOnEndCooldown ?? 300_000,
leaveOnStop: playerOptions.leaveOnStop ?? true, leaveOnStop: playerOptions.leaveOnStop ?? true,
leaveOnStopCooldown: playerOptions.leaveOnStopCooldown ?? 60000, leaveOnStopCooldown: playerOptions.leaveOnStopCooldown ?? 300_000,
maxSize: playerOptions.maxQueueSize ?? 1000, maxSize: playerOptions.maxQueueSize ?? 1000,
maxHistorySize: playerOptions.maxHistorySize ?? 100, maxHistorySize: playerOptions.maxHistorySize ?? 100,
volume: playerOptions.defaultVolume ?? 50, volume: playerOptions.defaultVolume ?? 50,
+58
View File
@@ -0,0 +1,58 @@
const logger = require('../../services/logger');
const { embedOptions } = require('../../config');
const { notInVoiceChannel } = require('../../utils/validation/voiceChannelValidator');
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
module.exports = {
data: new SlashCommandBuilder()
.setName('stop')
.setDescription('Stop playing audio and clear the track queue.')
.setDMPermission(false),
// todo, allow command to be executed if bot is only member in voice channel
execute: async ({ interaction }) => {
if (await notInVoiceChannel(interaction)) {
return;
}
const queue = useQueue(interaction.guild.id);
if (!queue) {
logger.debug(
`[Shard ${interaction.guild.shardId}] User used command ${interaction.commandName} but there was no queue.`
);
return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setDescription(
`**${embedOptions.icons.warning} Oops!**\n_Hmm.._ It seems I am not in a voice channel!`
)
.setColor(embedOptions.colors.warning)
]
});
}
if (!queue.deleted) {
queue.clear();
queue.node.stop();
logger.debug(
`[Shard ${interaction.guild.shardId}] User used command ${interaction.commandName} and cleared the queue.`
);
}
return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setAuthor({
name: interaction.member.nickname || interaction.user.username,
iconURL: interaction.user.avatarURL()
})
.setDescription(
`**${embedOptions.icons.success} Stopped playing**\nStopped playing audio and cleared the track queue.\n\nTo play more music, use the **\`/play\`** command!`
)
.setColor(embedOptions.colors.success)
]
});
}
};
+3 -3
View File
@@ -102,11 +102,11 @@ module.exports.embedOptions = {
// Options for the discord-player player. // Options for the discord-player player.
module.exports.playerOptions = { module.exports.playerOptions = {
leaveOnEmpty: true, leaveOnEmpty: true,
leaveOnEmptyCooldown: 300000, leaveOnEmptyCooldown: 300_000,
leaveOnEnd: true, leaveOnEnd: true,
leaveOnEndCooldown: 300000, leaveOnEndCooldown: 300_000,
leaveOnStop: true, leaveOnStop: true,
leaveOnStopCooldown: 300000, leaveOnStopCooldown: 300_000,
defaultVolume: 50, defaultVolume: 50,
maxQueueSize: 1000, maxQueueSize: 1000,
maxHistorySize: 100, maxHistorySize: 100,