From 7568caeaa97c3bc7ad61b7faace89141753e2921 Mon Sep 17 00:00:00 2001 From: HewkawAr Date: Sun, 11 Aug 2024 09:13:18 +0700 Subject: [PATCH 1/3] Clear queue command --- commands/Music/clear.js | 66 +++++++++++++++++++++++++++++++++++++++++ locales/en-US.json | 4 ++- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 commands/Music/clear.js diff --git a/commands/Music/clear.js b/commands/Music/clear.js new file mode 100644 index 0000000..453dfe7 --- /dev/null +++ b/commands/Music/clear.js @@ -0,0 +1,66 @@ +const { SlashCommandBuilder, EmbedBuilder, Colors, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("clear") + .setDescription("Clear Queue") + .setDescriptionLocalizations({ + th: "ล้างคิวเพลง" + }), + /** + * + * @param {import("discord.js").CommandInteraction} interaction + * @param {import("discord.js").Client} client + * @param {import("../../class/Locale")} locale + */ + async execute(interaction, client, locale) { + if (!interaction.member.voice.channel) return await interaction.reply({ embeds: [new EmbedBuilder().setColor(Colors.Yellow).setTitle(locale.getLocaleString("command.join.userNotInVoiceChannel"))] }); + + let player = client.moon.createPlayer({ + guildId: interaction.guild.id, + voiceChannelId: interaction.member.voice.channel.id, + textChannelId: interaction.channel.id, + autoLeave: true, + autoPlay: true + }); + + if (!player.connected) { + player.destroy(); + return interaction.reply({ + embeds: [ + new EmbedBuilder() + .setColor(Colors.Red) + .setDescription(locale.getLocaleString("command.skip.botNotInVoiceChannel")) + ] + }); + } + + const queue = player.queue.tracks; + + if (queue.length == 0) return interaction.reply({ + embeds: [ + new EmbedBuilder() + .setColor(Colors.Yellow) + .setTitle(locale.getLocaleString("command.queue.noqueue")) + ] + }); + + if (player.queue.clear()) { + return interaction.reply({ + embeds: [ + new EmbedBuilder() + .setColor(Colors.Green) + .setDescription(locale.getLocaleString("command.clear.success")) + ] + }); + } else { + return interaction.reply({ + embeds: [ + new EmbedBuilder() + .setColor(Colors.Red) + .setDescription(locale.getLocaleString("command.clear.fail")) + ] + }); + } + } +}; \ No newline at end of file diff --git a/locales/en-US.json b/locales/en-US.json index 36c9482..299b611 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -114,5 +114,7 @@ "command.ads.list": "Ads list", "moonlink.trackStart.withUrl": "{0} Start playing **[{1}]({2})**", "moonlink.trackStart.withoutUrl": "{0} Start playing **{1}**", - "moonlink.trackEnd": "There are no more tracks" + "moonlink.trackEnd": "There are no more tracks", + "command.clear.success": "🗑️ Clear Queue Success", + "command.clear.fail": "❌ Can't clear queue" } \ No newline at end of file From 9edc5771c2162bd37f15004eece33cd39f06c110 Mon Sep 17 00:00:00 2001 From: HewkawAr Date: Sun, 11 Aug 2024 09:13:21 +0700 Subject: [PATCH 2/3] Update crowdin.yml --- .github/workflows/crowdin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml index 0eabdbf..1903bd9 100644 --- a/.github/workflows/crowdin.yml +++ b/.github/workflows/crowdin.yml @@ -23,7 +23,7 @@ jobs: upload_sources: true upload_translations: false download_translations: true - localization_branch_name: l10n_crowdin_translations + localization_branch_name: crowdin_translations create_pull_request: true pull_request_title: "New Crowdin Translations" pull_request_body: "New Crowdin translations by [Crowdin GH Action](https://github.com/crowdin/github-action)" From fa9082af5f3dfd5734dd3b491d5afe1666087193 Mon Sep 17 00:00:00 2001 From: HewkawAr Date: Sun, 11 Aug 2024 09:14:59 +0700 Subject: [PATCH 3/3] Update clear.js 1:52 error 'ActionRowBuilder' is assigned a value but never used no-unused-vars 1:70 error 'ButtonBuilder' is assigned a value but never used no-unused-vars 1:85 error 'ButtonStyle' is assigned a value but never used no-unused-vars --- commands/Music/clear.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/Music/clear.js b/commands/Music/clear.js index 453dfe7..8ebe259 100644 --- a/commands/Music/clear.js +++ b/commands/Music/clear.js @@ -1,4 +1,4 @@ -const { SlashCommandBuilder, EmbedBuilder, Colors, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"); +const { SlashCommandBuilder, EmbedBuilder, Colors } = require("discord.js"); module.exports = { data: new SlashCommandBuilder()