feat: Music support #62

Merged
Anri merged 43 commits from feat/music into main 2023-02-12 01:11:10 +01:00
5 changed files with 31 additions and 12 deletions
Showing only changes of commit 8a5778d8b9 - Show all commits

View file

@ -5,9 +5,9 @@ import {
GuildResolvable,
VoiceBasedChannel,
} from "discord.js";
import { Metadata } from "../../modules/metadata";
import { getLocalizations } from "../../utils/locales";
import { getFilename } from "../../utils/misc";
import { Metadata } from "../../modules/metadata";
export default {
scope: () => [],
@ -68,7 +68,7 @@ export default {
const queue = client.player.createQueue(interaction.guild as GuildResolvable, {
metadata: {
channel: interaction.channel,
},
} as Metadata,
});
// Verify vc connection
@ -93,16 +93,8 @@ export default {
return await interaction.followUp({ content: `❌ | \`${query}\` introuvable.` });
}
// TMP
client.player.on("error", () => console.log("error"));
client.player.on("connectionError", () => console.log("error"));
client.player.on("trackStart", (q, t) =>
(q.metadata as Metadata).channel?.send(`🎶 | Joue \`${t.title}\`.`)
);
//
queue.play(track);
await queue.play(track);
return await interaction.followUp({ content: `⏱️ | Chargement de \`${track.title}\`.` });
return await interaction.followUp({ content: `⏱️ | Chargement de \`${track.title}\`...` });
},
};

View file

@ -1,3 +1,4 @@
import { PlayerEvents } from "discord-player";
import { Client } from "discord.js";
import { readdir } from "fs/promises";
@ -27,6 +28,13 @@ export default async (client: Client) => {
}
const event_type = event_type_ext.join(".");
if (event_category == "player") {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return client.player.on(event_type as keyof PlayerEvents, (...args: any) =>
execute(...args, client)
);
}
if (once) {
return client.once(event_type, (...args) => {
execute(...args, client);

View file

@ -0,0 +1,6 @@
import { Queue } from "discord-player";
/** https://discord-player.js.org/docs/main/master/typedef/PlayerEvents */
export default async (_: Queue, error: Error) => {
console.error(error);
};

View file

@ -0,0 +1,6 @@
import { Queue } from "discord-player";
/** https://discord-player.js.org/docs/main/master/typedef/PlayerEvents */
export default async (_: Queue, error: Error) => {
console.error(error);
};

View file

@ -0,0 +1,7 @@
import { Queue, Track } from "discord-player";
import { Metadata } from "../../modules/metadata";
/** https://discord-player.js.org/docs/main/master/typedef/PlayerEvents */
export default async (queue: Queue, track: Track) => {
(queue.metadata as Metadata).channel?.send(`🎶 | Joue \`${track.title}\`.`);
};