Skip to content

Commit

Permalink
chore: Add stop functionality to music commands
Browse files Browse the repository at this point in the history
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
Fyphen1223 authored Jun 8, 2024
1 parent c824a60 commit 60f7de7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
47 changes: 47 additions & 0 deletions commands/music/stop.js
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] });
},
};
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"paused": "⏸️ - Paused the music.",
"resumed": "▶️ - Resumed the music.",
"alreadyPaused": "🚫 - The music is already paused.",
"alreadyResumed": "🚫 - The music is already playing."
"alreadyResumed": "🚫 - The music is already playing.",
"stop": "⏹️ - Stopped the music."
},
"ping": "Pong! Current Ping is {ping}ms.",
"config": {
Expand Down
3 changes: 2 additions & 1 deletion lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"paused": "⏸️ - 音楽を一時停止しました。",
"resumed": "▶️ - 音楽を再開しました。",
"alreadyPaused": "🚫 - 音楽は既に一時停止しています。",
"alreadyResumed": "🚫 - 音楽は既に再生中です。"
"alreadyResumed": "🚫 - 音楽は既に再生中です。",
"stop": "⏹️ - 音楽を停止しました。"
},
"ping": "Pong! 現在のpingは {ping}ms です。",
"config": {
Expand Down

0 comments on commit 60f7de7

Please sign in to comment.