feat: Music support #62
2 changed files with 119 additions and 1 deletions
102
src/commands/music/repeat.ts
Normal file
102
src/commands/music/repeat.ts
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
|
import { QueueRepeatMode } from "discord-player";
|
||||||
|
import { ChatInputCommandInteraction, Client } from "discord.js";
|
||||||
|
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`))
|
||||||
|
|
||||||
|
// Disable repeat
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
|
.setName(loc_default.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "")
|
||||||
|
.setDescription(loc_default.get(`c_${filename}_sub1_desc`) ?? "")
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub1_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub1_desc`))
|
||||||
|
)
|
||||||
|
|
||||||
|
// Repeat current track
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
|
.setName(loc_default.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "")
|
||||||
|
.setDescription(loc_default.get(`c_${filename}_sub2_desc`) ?? "")
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub2_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub2_desc`))
|
||||||
|
)
|
||||||
|
|
||||||
|
// Repeat queue
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
|
.setName(loc_default.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "")
|
||||||
|
.setDescription(loc_default.get(`c_${filename}_sub3_desc`) ?? "")
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub3_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub3_desc`))
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enable autoplay
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
|
.setName(loc_default.get(`c_${filename}_sub4_name`)?.toLowerCase() ?? "")
|
||||||
|
.setDescription(loc_default.get(`c_${filename}_sub4_desc`) ?? "")
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub4_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub4_desc`))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
|
||||||
|
const loc_default = client.locales.get(client.config.default_lang);
|
||||||
|
const filename = getFilename(__filename);
|
||||||
|
|
||||||
|
const loc = getLocale(client, interaction.locale);
|
||||||
|
const queue = client.player.queues.get(interaction.guildId ?? "");
|
||||||
|
|
||||||
|
if (queue) {
|
||||||
|
const subcommand = interaction.options.getSubcommand();
|
||||||
|
switch (subcommand) {
|
||||||
|
// Disable
|
||||||
|
case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "": {
|
||||||
|
queue.setRepeatMode(QueueRepeatMode.OFF);
|
||||||
|
return interaction.reply(loc.get("c_repeat2"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Queue Repeat
|
||||||
|
case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "": {
|
||||||
|
queue.setRepeatMode(QueueRepeatMode.QUEUE);
|
||||||
|
return interaction.reply(loc.get("c_repeat3") + " " + loc.get("c_repeat6"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Autoplay
|
||||||
|
case loc_default?.get(`c_${filename}_sub4_name`)?.toLowerCase() ?? "": {
|
||||||
|
queue.setRepeatMode(QueueRepeatMode.AUTOPLAY);
|
||||||
|
return interaction.reply(loc.get("c_repeat4") + " " + loc.get("c_repeat6"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track repeat
|
||||||
|
case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "": {
|
||||||
|
queue.setRepeatMode(QueueRepeatMode.TRACK);
|
||||||
|
return interaction.reply(
|
||||||
|
loc.get("c_repeat5") + ` ${queue.nowPlaying()?.title} ` + loc.get("c_repeat6")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return await interaction.reply(loc.get("c_repeat1"));
|
||||||
|
},
|
||||||
|
};
|
|
@ -115,5 +115,21 @@
|
||||||
"c_lyrics_opt1_desc": "Chanson recherchée",
|
"c_lyrics_opt1_desc": "Chanson recherchée",
|
||||||
"c_lyrics1": "Le bot ne joue rien en ce moment et aucune chanson n'est renseignée.",
|
"c_lyrics1": "Le bot ne joue rien en ce moment et aucune chanson n'est renseignée.",
|
||||||
"c_lyrics2": "Paroles trop longues pour être affichées.",
|
"c_lyrics2": "Paroles trop longues pour être affichées.",
|
||||||
"c_lyrics3": "Impossible de trouver les paroles pour"
|
"c_lyrics3": "Impossible de trouver les paroles pour",
|
||||||
|
"c_repeat_name": "repeat",
|
||||||
|
"c_repeat_desc": "Commande relative à la répétition des musiques",
|
||||||
|
"c_repeat_sub1_name": "stop",
|
||||||
|
"c_repeat_sub1_desc": "Désactive la répétition",
|
||||||
|
"c_repeat_sub2_name": "track",
|
||||||
|
"c_repeat_sub2_desc": "Active la répétition pour la chanson en cours",
|
||||||
|
"c_repeat_sub3_name": "queue",
|
||||||
|
"c_repeat_sub3_desc": "Active la répétition pour la file actuelle",
|
||||||
|
"c_repeat_sub4_name": "autoplay",
|
||||||
|
"c_repeat_sub4_desc": "Active la lecture automatique",
|
||||||
|
"c_repeat1": "Le bot ne joue rien en ce moment.",
|
||||||
|
"c_repeat2": "Répétition désactivé.",
|
||||||
|
"c_repeat3": "Répétition de la file d'attente",
|
||||||
|
"c_repeat4": "Lecture automatique",
|
||||||
|
"c_repeat5": "Répétition de la chanson",
|
||||||
|
"c_repeat6": "activé."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue