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