This commit is contained in:
parent
d521a2fe8c
commit
2a7859f396
19 changed files with 413 additions and 343 deletions
|
@ -13,7 +13,7 @@
|
|||
> Installer les dépendances du bot
|
||||
|
||||
```bash
|
||||
npm install --legacy-peer-deps
|
||||
npm install
|
||||
```
|
||||
|
||||
> Lancer le bot
|
||||
|
|
628
package-lock.json
generated
628
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -16,23 +16,24 @@
|
|||
"author": "La confrérie du Kassoulait",
|
||||
"license": "GPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@discord-player/extractor": "^4.0.0",
|
||||
"@discord-player/extractor": "^4.1.0",
|
||||
"@discordjs/opus": "^0.9.0",
|
||||
"@discordjs/rest": "^1.5.0",
|
||||
"@types/sqlite3": "^3.1.8",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"discord-api-types": "^0.37.32",
|
||||
"discord-player": "^5.4.1-dev.0",
|
||||
"discord-player": "^6.0.0",
|
||||
"discord.js": "^14.7.1",
|
||||
"ffmpeg-static": "^5.1.0",
|
||||
"genius-lyrics": "^4.4.3",
|
||||
"node-fetch": "^2.6.9",
|
||||
"play-dl": "^1.9.6",
|
||||
"prism-media": "^1.3.4",
|
||||
"sqlite3": "^5.1.4",
|
||||
"typescript": "^4.9.5",
|
||||
"uuid": "^9.0.0"
|
||||
},
|
||||
"overrides": {
|
||||
"discord-api-types": "0.37.20"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
||||
"@typescript-eslint/parser": "^5.30.7",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Player } from "discord-player";
|
||||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
|
@ -29,8 +30,11 @@ export default {
|
|||
page++;
|
||||
}
|
||||
|
||||
// Get player
|
||||
const player = Player.singleton(client);
|
||||
|
||||
// Get queue
|
||||
const queue = client.player.queues.get(interaction.guildId ?? "");
|
||||
const queue = player.queues.get(interaction.guildId ?? "");
|
||||
|
||||
const embed = new EmbedBuilder();
|
||||
const rows = [];
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Player } from "discord-player";
|
||||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
|
@ -29,8 +30,11 @@ export default {
|
|||
page--;
|
||||
}
|
||||
|
||||
// Get player
|
||||
const player = Player.singleton(client);
|
||||
|
||||
// Get queue
|
||||
const queue = client.player.queues.get(interaction.guildId ?? "");
|
||||
const queue = player.queues.get(interaction.guildId ?? "");
|
||||
|
||||
const embed = new EmbedBuilder();
|
||||
const rows = [];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import { Player } from "discord-player";
|
||||
import { ChatInputCommandInteraction, Client, EmbedBuilder } from "discord.js";
|
||||
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||
import { getFilename } from "../../utils/misc";
|
||||
|
@ -44,19 +45,20 @@ export default {
|
|||
let data = null;
|
||||
await interaction.deferReply();
|
||||
|
||||
const player = Player.singleton(client);
|
||||
if (request) {
|
||||
try {
|
||||
data = await client.player.lyrics.search(request);
|
||||
data = await player.lyrics.search(request);
|
||||
} catch {
|
||||
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${request}\``);
|
||||
}
|
||||
} else {
|
||||
const queue = client.player.queues.get(interaction.guildId ?? "");
|
||||
const queue = player.queues.get(interaction.guildId ?? "");
|
||||
if (queue) {
|
||||
const title = queue.current?.title;
|
||||
const title = queue.history.currentTrack?.title;
|
||||
if (title) {
|
||||
try {
|
||||
data = await client.player.lyrics.search(title + " " + queue.current.author);
|
||||
data = await player.lyrics.search(title + " " + queue.history.currentTrack?.author);
|
||||
} catch {
|
||||
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${title}\``);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import { Player } from "discord-player";
|
||||
import { ChatInputCommandInteraction, Client, EmbedBuilder } from "discord.js";
|
||||
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||
import { getFilename } from "../../utils/misc";
|
||||
|
@ -22,17 +23,18 @@ export default {
|
|||
|
||||
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
|
||||
const loc = getLocale(client, interaction.locale);
|
||||
const queue = client.player.queues.get(interaction.guildId ?? "");
|
||||
const player = Player.singleton(client);
|
||||
const queue = player.queues.get(interaction.guildId ?? "");
|
||||
|
||||
if (queue) {
|
||||
const embed = new EmbedBuilder();
|
||||
if (queue.paused) {
|
||||
queue.resume();
|
||||
if (queue.node.isPaused()) {
|
||||
queue.node.resume();
|
||||
|
||||
embed.setDescription(loc.get("c_pause1"));
|
||||
return await interaction.reply({ embeds: [embed] });
|
||||
} else {
|
||||
queue.pause();
|
||||
queue.node.pause();
|
||||
|
||||
embed.setDescription(loc.get("c_pause2"));
|
||||
return await interaction.reply({ embeds: [embed] });
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
import { Metadata } from "../../utils/metadata";
|
||||
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||
import { getFilename } from "../../utils/misc";
|
||||
import { Player } from "discord-player";
|
||||
|
||||
export default {
|
||||
scope: () => [],
|
||||
|
@ -68,17 +69,18 @@ export default {
|
|||
loc_default?.get(`c_${filename}_opt1_name`) as string
|
||||
);
|
||||
|
||||
const player = Player.singleton(client);
|
||||
if (!query) {
|
||||
// Now playing
|
||||
|
||||
const queue = client.player.queues.get(interaction.guildId ?? "");
|
||||
const queue = player.queues.get(interaction.guildId ?? "");
|
||||
|
||||
if (queue) {
|
||||
const track = queue.nowPlaying();
|
||||
const track = queue.history.currentTrack;
|
||||
if (track) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(
|
||||
`${queue.createProgressBar()}\n\n${loc.get("c_play8")} ${track.requestedBy}`
|
||||
`${queue.node.createProgressBar()}\n\n${loc.get("c_play8")} ${track.requestedBy}`
|
||||
)
|
||||
.setTitle(track.title + " • " + track.author)
|
||||
.setURL(track.url)
|
||||
|
@ -93,7 +95,7 @@ export default {
|
|||
return await interaction.reply({ embeds: [embed] });
|
||||
}
|
||||
|
||||
const queue = client.player.createQueue(interaction.guild as GuildResolvable, {
|
||||
const queue = player.nodes.create(interaction.guild as GuildResolvable, {
|
||||
metadata: {
|
||||
channel: interaction.channel,
|
||||
} as Metadata,
|
||||
|
@ -103,7 +105,7 @@ export default {
|
|||
try {
|
||||
if (!queue.connection) await queue.connect(member.voice.channel as VoiceBasedChannel);
|
||||
} catch {
|
||||
queue.destroy();
|
||||
queue.delete();
|
||||
return await interaction.reply({
|
||||
content: `❌ | ${loc.get("c_play3")}`,
|
||||
ephemeral: true,
|
||||
|
@ -111,7 +113,7 @@ export default {
|
|||
}
|
||||
|
||||
await interaction.deferReply();
|
||||
const result = await client.player
|
||||
const result = await player
|
||||
.search(query, {
|
||||
requestedBy: interaction.user,
|
||||
})
|
||||
|
@ -124,7 +126,7 @@ export default {
|
|||
|
||||
let title;
|
||||
if (result.playlist) {
|
||||
queue.addTracks(result.playlist.tracks);
|
||||
queue.addTrack(result.playlist.tracks);
|
||||
title = result.playlist.title;
|
||||
} else {
|
||||
// TODO: Ask user which result to choose
|
||||
|
@ -134,8 +136,8 @@ export default {
|
|||
title = track.title;
|
||||
}
|
||||
|
||||
if (!queue.playing) {
|
||||
queue.play();
|
||||
if (!queue.node.isPlaying()) {
|
||||
queue.node.play();
|
||||
}
|
||||
|
||||
return await interaction.followUp({
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import { Player } from "discord-player";
|
||||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
|
@ -92,7 +93,8 @@ export default {
|
|||
const filename = getFilename(__filename);
|
||||
|
||||
const loc = getLocale(client, interaction.locale);
|
||||
const queue = client.player.queues.get(interaction.guildId ?? "");
|
||||
const player = Player.singleton(client);
|
||||
const queue = player.queues.get(interaction.guildId ?? "");
|
||||
|
||||
const embed = new EmbedBuilder();
|
||||
const rows = [];
|
||||
|
@ -136,7 +138,7 @@ export default {
|
|||
|
||||
// Shuffle Queue
|
||||
case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "": {
|
||||
queue.shuffle();
|
||||
queue.tracks.shuffle();
|
||||
|
||||
embed.setDescription(loc.get("c_queue3"));
|
||||
break;
|
||||
|
@ -148,7 +150,7 @@ export default {
|
|||
loc_default?.get(`c_${filename}_sub3_opt1_name`) as string
|
||||
) as number;
|
||||
|
||||
const track = queue.remove(id - 1);
|
||||
const track = queue.removeTrack(id - 1);
|
||||
|
||||
if (track) {
|
||||
embed.setDescription(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import { QueueRepeatMode } from "discord-player";
|
||||
import { Player, QueueRepeatMode } from "discord-player";
|
||||
import { ChatInputCommandInteraction, Client } from "discord.js";
|
||||
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||
import { getFilename } from "../../utils/misc";
|
||||
|
@ -64,7 +64,8 @@ export default {
|
|||
const filename = getFilename(__filename);
|
||||
|
||||
const loc = getLocale(client, interaction.locale);
|
||||
const queue = client.player.queues.get(interaction.guildId ?? "");
|
||||
const player = Player.singleton(client);
|
||||
const queue = player.queues.get(interaction.guildId ?? "");
|
||||
|
||||
if (queue) {
|
||||
const subcommand = interaction.options.getSubcommand();
|
||||
|
@ -91,7 +92,7 @@ export default {
|
|||
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")}.`
|
||||
`${loc.get("c_repeat5")} ${queue.history.currentTrack?.title} ${loc.get("c_repeat6")}.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import { Player } from "discord-player";
|
||||
import { ChatInputCommandInteraction, Client } from "discord.js";
|
||||
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||
import { getFilename } from "../../utils/misc";
|
||||
|
@ -36,17 +37,18 @@ export default {
|
|||
const filename = getFilename(__filename);
|
||||
|
||||
const loc = getLocale(client, interaction.locale);
|
||||
const queue = client.player.queues.get(interaction.guildId ?? "");
|
||||
const player = Player.singleton(client);
|
||||
const queue = player.queues.get(interaction.guildId ?? "");
|
||||
|
||||
const id = interaction.options.getNumber(loc_default?.get(`c_${filename}_opt1_name`) as string);
|
||||
|
||||
if (queue) {
|
||||
let msg;
|
||||
if (id) {
|
||||
queue.skipTo(id - 1);
|
||||
queue.node.skipTo(id - 1);
|
||||
msg = loc.get("c_skip3") + " #" + id + "...";
|
||||
} else {
|
||||
queue.skip();
|
||||
queue.node.skip();
|
||||
msg = loc.get("c_skip1") + "...";
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import { ChatInputCommandInteraction, Client, GuildResolvable } from "discord.js
|
|||
import { Metadata } from "../../utils/metadata";
|
||||
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||
import { getFilename } from "../../utils/misc";
|
||||
import { Player } from "discord-player";
|
||||
|
||||
export default {
|
||||
scope: () => [],
|
||||
|
@ -24,17 +25,18 @@ export default {
|
|||
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
|
||||
const loc = getLocale(client, interaction.locale);
|
||||
|
||||
const queue = client.player.createQueue(interaction.guild as GuildResolvable, {
|
||||
const player = Player.singleton(client);
|
||||
const queue = player.nodes.create(interaction.guild as GuildResolvable, {
|
||||
metadata: {
|
||||
channel: interaction.channel,
|
||||
} as Metadata,
|
||||
});
|
||||
|
||||
if (!(queue.connection || queue.playing)) {
|
||||
if (!(queue.connection || queue.node.isPlaying())) {
|
||||
return interaction.reply(`❌ | ${loc.get("c_stop1")}`);
|
||||
}
|
||||
|
||||
queue.destroy();
|
||||
queue.delete();
|
||||
|
||||
interaction.reply(loc.get("c_stop2"));
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PlayerEvents } from "discord-player";
|
||||
import { Player, PlayerEvents } from "discord-player";
|
||||
import { Client } from "discord.js";
|
||||
import { readdir } from "fs/promises";
|
||||
|
||||
|
@ -29,14 +29,15 @@ export default async (client: Client) => {
|
|||
const event_type = event_type_ext.join(".");
|
||||
|
||||
if (event_category == "player") {
|
||||
const player = Player.singleton(client);
|
||||
if (once) {
|
||||
// eslint-disable-next-line
|
||||
return client.player.once(event_type as keyof PlayerEvents, (...args: any[]) => {
|
||||
return player.events.once(event_type as keyof PlayerEvents, (...args: any[]) => {
|
||||
execute(...args, client);
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
return client.player.on(event_type as keyof PlayerEvents, (...args: any[]) => {
|
||||
return player.events.on(event_type as keyof PlayerEvents, (...args: any[]) => {
|
||||
execute(...args, client);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Queue } from "discord-player";
|
||||
import { GuildQueue } from "discord-player";
|
||||
import { Metadata } from "../../utils/metadata";
|
||||
|
||||
/** https://discord-player.js.org/docs/main/master/typedef/PlayerEvents */
|
||||
export default (_: Queue<Metadata>, error: Error) => {
|
||||
export default (_: GuildQueue<Metadata>, error: Error) => {
|
||||
console.error(error);
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Queue } from "discord-player";
|
||||
import { GuildQueue } from "discord-player";
|
||||
import { Metadata } from "../../utils/metadata";
|
||||
|
||||
/** https://discord-player.js.org/docs/main/master/typedef/PlayerEvents */
|
||||
export default (_: Queue<Metadata>, error: Error) => {
|
||||
export default (_: GuildQueue<Metadata>, error: Error) => {
|
||||
console.error(error);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { EmbedBuilder } from "@discordjs/builders";
|
||||
import { Queue, Track } from "discord-player";
|
||||
import { GuildQueue, Track } from "discord-player";
|
||||
import { Client } from "discord.js";
|
||||
import { Metadata } from "../../utils/metadata";
|
||||
import { emojiPng } from "../../utils/misc";
|
||||
|
||||
/** https://discord-player.js.org/docs/main/master/typedef/PlayerEvents */
|
||||
export default (queue: Queue<Metadata>, track: Track, client: Client) => {
|
||||
export default (queue: GuildQueue<Metadata>, track: Track, client: Client) => {
|
||||
const loc_default = client.locales.get(client.config.default_lang);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { Collection } from "discord.js";
|
||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import { Database } from "sqlite3";
|
||||
import { Player } from "discord-player";
|
||||
|
||||
export {};
|
||||
|
||||
|
@ -83,8 +82,6 @@ declare module "discord.js" {
|
|||
}
|
||||
>;
|
||||
};
|
||||
/** Music player */
|
||||
player: Player;
|
||||
/** Store all the localizations */
|
||||
locales: Map<string, Map<string, string>>;
|
||||
db: Database;
|
||||
|
|
|
@ -38,13 +38,13 @@ export default async () => {
|
|||
list: new Collection(),
|
||||
};
|
||||
|
||||
client.player = new Player(client, {
|
||||
const player = Player.singleton(client, {
|
||||
ytdlOptions: {
|
||||
filter: "audioonly",
|
||||
},
|
||||
});
|
||||
|
||||
client.player.lyrics = lyricsExtractor();
|
||||
player.lyrics = lyricsExtractor();
|
||||
|
||||
console.log("Translations progression :");
|
||||
client.locales = await loadLocales(client.config.default_lang);
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
import { EmbedBuilder } from "@discordjs/builders";
|
||||
import { Queue, QueueRepeatMode, Track } from "discord-player";
|
||||
import { GuildQueue, QueueRepeatMode, Track } from "discord-player";
|
||||
import { Client } from "discord.js";
|
||||
import { getLocale } from "./locales";
|
||||
|
||||
export const embedListQueue = (
|
||||
client: Client,
|
||||
embed: EmbedBuilder,
|
||||
queue: Queue,
|
||||
queue: GuildQueue,
|
||||
page: number,
|
||||
local: string
|
||||
) => {
|
||||
const loc = getLocale(client, local);
|
||||
const tracks = queue.tracks.slice();
|
||||
const tracks = queue.tracks.toArray();
|
||||
|
||||
// Add the current song at the top of the list
|
||||
tracks.unshift(queue.current as Track);
|
||||
tracks.unshift(queue.history.currentTrack as Track);
|
||||
|
||||
// Limit of discord is 25
|
||||
const limit_fields = 25;
|
||||
|
|
Loading…
Reference in a new issue