Merge pull request #104 from mariusbegby/stop-command

Stop command
This commit is contained in:
Marius Begby authored and GitHub committed 2023-07-23 12:30:12 +02:00
commit 7e0479c299
5 files changed
+81 -22

No files matched your search

+3 -2
View File
@@ -16,12 +16,13 @@ module.exports = {
'- **`/pause`** - Pause or resume the current track.\n' +
'- **`/queue` `[page]`** - Show the list of tracks added to the queue.\n' +
'- **`/nowplaying`** - Show information about the track currently playing.\n' +
`- **\`/seek\` \`duration\`** - ${embedOptions.icons.new} Seek to a specified duration in the current track.\n` +
'- **`/seek` `duration`** - Seek to a specified duration in the current track.\n' +
`- **\`/loop\` \`mode\`** - ${embedOptions.icons.beta} Toggle looping a track, the whole queue or autoplay.\n` +
'- **`/filters`** - Toggle various audio filters during playback.\n' +
`- **\`/filters\`** - ${embedOptions.icons.beta} Toggle various audio filters during playback.\n` +
'- **`/volume` `[percentage]`** - Show or set the playback volume for tracks.\n' +
'- **`/skip` `[tracknumber]`** - Skip to next or specified track.\n' +
'- **`/remove` `tracknumber`** - Remove specified track from the queue.\n' +
`- **\`/stop\`** - ${embedOptions.icons.new} Stop playing audio and clear the track queue.\n` +
'- **`/leave`** - Clear the queue and remove the bot from voice channel.\n\n' +
`${embedOptions.icons.support} **Support server**\nJoin the support server for help or suggestions: \n**${botOptions.serverInviteUrl}**\n\n` +
`${embedOptions.icons.bot} **Enjoying ${botOptions.name}?**\nAdd me to another server: \n**[Click me!](${botOptions.botInviteUrl})**`
+14 -14
View File
@@ -38,20 +38,20 @@ module.exports = {
logger.debug(
`[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,
nodeOptions: {
leaveOnEmpty: playerOptions.leaveOnEmpty ?? true,
leaveOnEmptyCooldown: playerOptions.leaveOnEmptyCooldown ?? 60000,
leaveOnEmptyCooldown: playerOptions.leaveOnEmptyCooldown ?? 300_000,
leaveOnEnd: playerOptions.leaveOnEnd ?? true,
leaveOnEndCooldown: playerOptions.leaveOnEndCooldown ?? 60000,
leaveOnEndCooldown: playerOptions.leaveOnEndCooldown ?? 300_000,
leaveOnStop: playerOptions.leaveOnStop ?? true,
leaveOnStopCooldown: playerOptions.leaveOnStopCooldown ?? 60000,
leaveOnStopCooldown: playerOptions.leaveOnStopCooldown ?? 300_000,
maxSize: playerOptions.maxQueueSize ?? 1000,
maxHistorySize: playerOptions.maxHistorySize ?? 100,
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.
module.exports.playerOptions = {
leaveOnEmpty: true,
leaveOnEmptyCooldown: 300000,
leaveOnEmptyCooldown: 300_000,
leaveOnEnd: true,
leaveOnEndCooldown: 300000,
leaveOnEndCooldown: 300_000,
leaveOnStop: true,
leaveOnStopCooldown: 300000,
leaveOnStopCooldown: 300_000,
defaultVolume: 50,
maxQueueSize: 1000,
maxHistorySize: 100,