-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add stop functionality to music commands
This commit adds the "stop" functionality to the music commands in both the `en.json` and `ja.json` files. It includes the translation for the "stop" action and updates the language files accordingly. Note: The commit message has been generated based on the provided code changes and recent repository commits.
- Loading branch information
1 parent
c824a60
commit 60f7de7
Showing
3 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const { getLocale } = require('../../lang/lang.js'); | ||
const { createMessageEmbed } = require('../../util/embed.js'); | ||
|
||
const guilds = require('../../data/guilds.json'); | ||
|
||
const { SlashCommandBuilder } = require('discord.js'); | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder().setName('stop').setDescription('Stop playback'), | ||
info: { | ||
premium: false, | ||
}, | ||
async execute(interaction) { | ||
await interaction.deferReply(); | ||
|
||
const guildId = interaction.guild.id; | ||
if (!interaction.member.voice.channelId || !globalThis.queue[guildId]) { | ||
const noValidVCEmbed = createMessageEmbed( | ||
getLocale(guilds[guildId].locale).vc.noVC, | ||
interaction | ||
); | ||
await interaction.editReply({ embeds: [noValidVCEmbed] }); | ||
return; | ||
} | ||
|
||
if (globalThis.queue[guildId].voiceChannel) { | ||
if ( | ||
globalThis.queue[guildId].voiceChannel.id !== | ||
interaction.member.voice.channelId | ||
) { | ||
const differentVCEmbed = createMessageEmbed( | ||
getLocale(guilds[guildId].locale).vc.differentVC, | ||
interaction | ||
); | ||
await interaction.editReply({ embeds: [differentVCEmbed] }); | ||
return; | ||
} | ||
} | ||
|
||
await globalThis.queue[guildId].player.stop(); | ||
await globalThis.queue[guildId].player.node.leaveVoiceChannel(guildId); | ||
|
||
const embed = createMessageEmbed(getLocale(guilds[guildId].locale).vc.stop); | ||
|
||
await interaction.editReply({ embeds: [embed] }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters