mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
feat: added /stop command
This commit is contained in:
1 parent
52f1dd2dea
commit
3c52841cd6
4 files changed
+78
-20
No files matched your search
@@ -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)
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user