Skip to content
This repository was archived by the owner on Sep 28, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
66 changes: 66 additions & 0 deletions commands/Music/clear.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const { SlashCommandBuilder, EmbedBuilder, Colors } = 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"))
]
});
}
}
};
4 changes: 3 additions & 1 deletion locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}