add stop command
This commit is contained in:
parent
54847dbc49
commit
ae5f8799a8
2 changed files with 46 additions and 1 deletions
41
src/commands/music/stop.ts
Normal file
41
src/commands/music/stop.ts
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
|
import { ChatInputCommandInteraction, Client, GuildResolvable } from "discord.js";
|
||||||
|
import { Metadata } from "../../modules/metadata";
|
||||||
|
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||||
|
import { getFilename } from "../../utils/misc";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
scope: () => [],
|
||||||
|
|
||||||
|
data: (client: Client) => {
|
||||||
|
const filename = getFilename(__filename);
|
||||||
|
const loc_default = client.locales.get(client.config.default_lang);
|
||||||
|
if (!loc_default) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SlashCommandBuilder()
|
||||||
|
.setName(filename.toLowerCase())
|
||||||
|
.setDescription(loc_default.get(`c_${filename}_desc`) ?? "")
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`));
|
||||||
|
},
|
||||||
|
|
||||||
|
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
|
||||||
|
const loc = getLocale(client, interaction.locale);
|
||||||
|
|
||||||
|
const queue = client.player.createQueue(interaction.guild as GuildResolvable, {
|
||||||
|
metadata: {
|
||||||
|
channel: interaction.channel,
|
||||||
|
} as Metadata,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!(queue.connection || queue.playing)) {
|
||||||
|
return interaction.reply(loc.get("c_stop1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.destroy();
|
||||||
|
|
||||||
|
interaction.reply(loc.get("c_stop2"));
|
||||||
|
},
|
||||||
|
};
|
|
@ -81,5 +81,9 @@
|
||||||
"c_play_name": "play",
|
"c_play_name": "play",
|
||||||
"c_play_desc": "Joue une chanson/playlist",
|
"c_play_desc": "Joue une chanson/playlist",
|
||||||
"c_play_opt1_name": "requête",
|
"c_play_opt1_name": "requête",
|
||||||
"c_play_opt1_desc": "Ce que vous voulez écouter"
|
"c_play_opt1_desc": "Ce que vous voulez écouter",
|
||||||
|
"c_stop_name": "stop",
|
||||||
|
"c_stop_desc": "Stop la musique",
|
||||||
|
"c_stop1": "Le bot ne joue pas de musique.",
|
||||||
|
"c_stop2": "La musique à été arrêtée."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue