feat: Music support #62
5 changed files with 31 additions and 12 deletions
|
@ -5,9 +5,9 @@ import {
|
||||||
GuildResolvable,
|
GuildResolvable,
|
||||||
VoiceBasedChannel,
|
VoiceBasedChannel,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
|
import { Metadata } from "../../modules/metadata";
|
||||||
import { getLocalizations } from "../../utils/locales";
|
import { getLocalizations } from "../../utils/locales";
|
||||||
import { getFilename } from "../../utils/misc";
|
import { getFilename } from "../../utils/misc";
|
||||||
import { Metadata } from "../../modules/metadata";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
scope: () => [],
|
scope: () => [],
|
||||||
|
@ -68,7 +68,7 @@ export default {
|
||||||
const queue = client.player.createQueue(interaction.guild as GuildResolvable, {
|
const queue = client.player.createQueue(interaction.guild as GuildResolvable, {
|
||||||
metadata: {
|
metadata: {
|
||||||
channel: interaction.channel,
|
channel: interaction.channel,
|
||||||
},
|
} as Metadata,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verify vc connection
|
// Verify vc connection
|
||||||
|
@ -93,16 +93,8 @@ export default {
|
||||||
return await interaction.followUp({ content: `❌ | \`${query}\` introuvable.` });
|
return await interaction.followUp({ content: `❌ | \`${query}\` introuvable.` });
|
||||||
}
|
}
|
||||||
|
|
||||||
// TMP
|
queue.play(track);
|
||||||
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}\`.`)
|
|
||||||
);
|
|
||||||
//
|
|
||||||
|
|
||||||
await queue.play(track);
|
return await interaction.followUp({ content: `⏱️ | Chargement de \`${track.title}\`...` });
|
||||||
|
|
||||||
return await interaction.followUp({ content: `⏱️ | Chargement de \`${track.title}\`.` });
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { PlayerEvents } from "discord-player";
|
||||||
import { Client } from "discord.js";
|
import { Client } from "discord.js";
|
||||||
import { readdir } from "fs/promises";
|
import { readdir } from "fs/promises";
|
||||||
|
|
||||||
|
@ -27,6 +28,13 @@ export default async (client: Client) => {
|
||||||
}
|
}
|
||||||
const event_type = event_type_ext.join(".");
|
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) {
|
if (once) {
|
||||||
return client.once(event_type, (...args) => {
|
return client.once(event_type, (...args) => {
|
||||||
execute(...args, client);
|
execute(...args, client);
|
||||||
|
|
6
src/events/player/connectionError.ts
Normal file
6
src/events/player/connectionError.ts
Normal 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);
|
||||||
|
};
|
6
src/events/player/error.ts
Normal file
6
src/events/player/error.ts
Normal 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);
|
||||||
|
};
|
7
src/events/player/trackStart.ts
Normal file
7
src/events/player/trackStart.ts
Normal 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}\`.`);
|
||||||
|
};
|
Loading…
Reference in a new issue