update to discord-player-v6 #76

Merged
Anri merged 30 commits from feat/music-v6 into main 2023-03-11 20:36:25 +01:00
12 changed files with 19 additions and 42 deletions
Showing only changes of commit b9a7f6090d - Show all commits

View file

@ -1,4 +1,4 @@
import { Player } from "discord-player";
import { useQueue } from "discord-player";
import {
ActionRowBuilder,
ButtonBuilder,
@ -30,11 +30,8 @@ export default {
page++;
}
// Get player
const player = Player.singleton(client);
// Get queue
const queue = player.queues.get(interaction.guildId ?? "");
const queue = useQueue(interaction.guildId ?? "");
const embed = new EmbedBuilder();
const rows = [];

View file

@ -1,4 +1,4 @@
import { Player } from "discord-player";
import { useQueue } from "discord-player";
import {
ActionRowBuilder,
ButtonBuilder,
@ -30,11 +30,8 @@ export default {
page--;
}
// Get player
const player = Player.singleton(client);
// Get queue
const queue = player.queues.get(interaction.guildId ?? "");
const queue = useQueue(interaction.guildId ?? "");
const embed = new EmbedBuilder();
const rows = [];

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { Player } from "discord-player";
import { Player, useQueue } from "discord-player";
import { ChatInputCommandInteraction, Client, EmbedBuilder } from "discord.js";
import { getLocale, getLocalizations } from "../../utils/locales";
import { getFilename } from "../../utils/misc";
@ -53,7 +53,7 @@ export default {
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${request}\``);
}
} else {
const queue = player.queues.get(interaction.guildId ?? "");
const queue = useQueue(interaction.guildId ?? "");
if (queue) {
const title = queue.history.currentTrack?.title;
if (title) {

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { Player } from "discord-player";
import { useQueue } from "discord-player";
import { ChatInputCommandInteraction, Client, EmbedBuilder } from "discord.js";
import { getLocale, getLocalizations } from "../../utils/locales";
import { getFilename } from "../../utils/misc";
@ -23,8 +23,7 @@ export default {
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
const loc = getLocale(client, interaction.locale);
const player = Player.singleton(client);
const queue = player.queues.get(interaction.guildId ?? "");
const queue = useQueue(interaction.guildId ?? "");
if (queue) {
const embed = new EmbedBuilder();

View file

@ -9,7 +9,7 @@ import {
import { Metadata } from "../../utils/metadata";
import { getLocale, getLocalizations } from "../../utils/locales";
import { getFilename } from "../../utils/misc";
import { Player } from "discord-player";
import { Player, useQueue } from "discord-player";
export default {
scope: () => [],
@ -73,7 +73,7 @@ export default {
if (!query) {
// Now playing
const queue = player.queues.get(interaction.guildId ?? "");
const queue = useQueue(interaction.guildId ?? "");
if (queue) {
const track = queue.history.currentTrack;
@ -130,6 +130,7 @@ export default {
title = result.playlist.title;
} else {
// TODO: Ask user which result to choose
// Maybe use https://discordjs.guide/interactions/select-menus.html#building-and-sending-select-menus ?
const track = result.tracks[0];
queue.addTrack(track);

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { Player } from "discord-player";
import { useQueue } from "discord-player";
import {
ActionRowBuilder,
ButtonBuilder,
@ -93,8 +93,7 @@ export default {
const filename = getFilename(__filename);
const loc = getLocale(client, interaction.locale);
const player = Player.singleton(client);
const queue = player.queues.get(interaction.guildId ?? "");
const queue = useQueue(interaction.guildId ?? "");
const embed = new EmbedBuilder();
const rows = [];

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { Player, QueueRepeatMode } from "discord-player";
import { QueueRepeatMode, useQueue } from "discord-player";
import { ChatInputCommandInteraction, Client } from "discord.js";
import { getLocale, getLocalizations } from "../../utils/locales";
import { getFilename } from "../../utils/misc";
@ -64,8 +64,7 @@ export default {
const filename = getFilename(__filename);
const loc = getLocale(client, interaction.locale);
const player = Player.singleton(client);
const queue = player.queues.get(interaction.guildId ?? "");
const queue = useQueue(interaction.guildId ?? "");
if (queue) {
const subcommand = interaction.options.getSubcommand();

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { Player } from "discord-player";
import { useQueue } from "discord-player";
import { ChatInputCommandInteraction, Client } from "discord.js";
import { getLocale, getLocalizations } from "../../utils/locales";
import { getFilename } from "../../utils/misc";
@ -37,8 +37,7 @@ export default {
const filename = getFilename(__filename);
const loc = getLocale(client, interaction.locale);
const player = Player.singleton(client);
const queue = player.queues.get(interaction.guildId ?? "");
const queue = useQueue(interaction.guildId ?? "");
const id = interaction.options.getNumber(loc_default?.get(`c_${filename}_opt1_name`) as string);

View file

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

View file

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

View file

@ -4,7 +4,7 @@ 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 */
/** https://discord-player.js.org/docs/types/discord-player/GuildQueueEvents */
export default (queue: GuildQueue<Metadata>, track: Track, client: Client) => {
const loc_default = client.locales.get(client.config.default_lang);

View file

@ -38,7 +38,7 @@ export default async () => {
list: new Collection(),
};
const player = Player.singleton(client, {
const player = new Player(client, {
ytdlOptions: {
filter: "audioonly",
},