update to discord-player-v6 #76
12 changed files with 19 additions and 42 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { Player } from "discord-player";
|
import { useQueue } from "discord-player";
|
||||||
import {
|
import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
|
@ -30,11 +30,8 @@ export default {
|
||||||
page++;
|
page++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get player
|
|
||||||
const player = Player.singleton(client);
|
|
||||||
|
|
||||||
// Get queue
|
// Get queue
|
||||||
const queue = player.queues.get(interaction.guildId ?? "");
|
const queue = useQueue(interaction.guildId ?? "");
|
||||||
|
|
||||||
const embed = new EmbedBuilder();
|
const embed = new EmbedBuilder();
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Player } from "discord-player";
|
import { useQueue } from "discord-player";
|
||||||
import {
|
import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
|
@ -30,11 +30,8 @@ export default {
|
||||||
page--;
|
page--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get player
|
|
||||||
const player = Player.singleton(client);
|
|
||||||
|
|
||||||
// Get queue
|
// Get queue
|
||||||
const queue = player.queues.get(interaction.guildId ?? "");
|
const queue = useQueue(interaction.guildId ?? "");
|
||||||
|
|
||||||
const embed = new EmbedBuilder();
|
const embed = new EmbedBuilder();
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { Player } from "discord-player";
|
import { Player, useQueue } 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";
|
||||||
|
@ -53,7 +53,7 @@ export default {
|
||||||
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${request}\``);
|
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${request}\``);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const queue = player.queues.get(interaction.guildId ?? "");
|
const queue = useQueue(interaction.guildId ?? "");
|
||||||
if (queue) {
|
if (queue) {
|
||||||
const title = queue.history.currentTrack?.title;
|
const title = queue.history.currentTrack?.title;
|
||||||
if (title) {
|
if (title) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { Player } from "discord-player";
|
import { useQueue } 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";
|
||||||
|
@ -23,8 +23,7 @@ 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 player = Player.singleton(client);
|
const queue = useQueue(interaction.guildId ?? "");
|
||||||
const queue = player.queues.get(interaction.guildId ?? "");
|
|
||||||
|
|
||||||
if (queue) {
|
if (queue) {
|
||||||
const embed = new EmbedBuilder();
|
const embed = new EmbedBuilder();
|
||||||
|
|
|
@ -9,7 +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";
|
import { Player, useQueue } from "discord-player";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
scope: () => [],
|
scope: () => [],
|
||||||
|
@ -73,7 +73,7 @@ export default {
|
||||||
if (!query) {
|
if (!query) {
|
||||||
// Now playing
|
// Now playing
|
||||||
|
|
||||||
const queue = player.queues.get(interaction.guildId ?? "");
|
const queue = useQueue(interaction.guildId ?? "");
|
||||||
|
|
||||||
if (queue) {
|
if (queue) {
|
||||||
const track = queue.history.currentTrack;
|
const track = queue.history.currentTrack;
|
||||||
|
@ -130,6 +130,7 @@ export default {
|
||||||
title = result.playlist.title;
|
title = result.playlist.title;
|
||||||
} else {
|
} else {
|
||||||
// TODO: Ask user which result to choose
|
// 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];
|
const track = result.tracks[0];
|
||||||
|
|
||||||
queue.addTrack(track);
|
queue.addTrack(track);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { Player } from "discord-player";
|
import { useQueue } from "discord-player";
|
||||||
import {
|
import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
|
@ -93,8 +93,7 @@ export default {
|
||||||
const filename = getFilename(__filename);
|
const filename = getFilename(__filename);
|
||||||
|
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
const player = Player.singleton(client);
|
const queue = useQueue(interaction.guildId ?? "");
|
||||||
const queue = player.queues.get(interaction.guildId ?? "");
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder();
|
const embed = new EmbedBuilder();
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { Player, QueueRepeatMode } from "discord-player";
|
import { QueueRepeatMode, useQueue } 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,8 +64,7 @@ export default {
|
||||||
const filename = getFilename(__filename);
|
const filename = getFilename(__filename);
|
||||||
|
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
const player = Player.singleton(client);
|
const queue = useQueue(interaction.guildId ?? "");
|
||||||
const queue = player.queues.get(interaction.guildId ?? "");
|
|
||||||
|
|
||||||
if (queue) {
|
if (queue) {
|
||||||
const subcommand = interaction.options.getSubcommand();
|
const subcommand = interaction.options.getSubcommand();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { Player } from "discord-player";
|
import { useQueue } 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";
|
||||||
|
@ -37,8 +37,7 @@ export default {
|
||||||
const filename = getFilename(__filename);
|
const filename = getFilename(__filename);
|
||||||
|
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
const player = Player.singleton(client);
|
const queue = useQueue(interaction.guildId ?? "");
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
|
||||||
};
|
|
|
@ -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);
|
|
||||||
};
|
|
|
@ -4,7 +4,7 @@ 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/types/discord-player/GuildQueueEvents */
|
||||||
export default (queue: GuildQueue<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);
|
||||||
|
|
|
@ -38,7 +38,7 @@ export default async () => {
|
||||||
list: new Collection(),
|
list: new Collection(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const player = Player.singleton(client, {
|
const player = new Player(client, {
|
||||||
ytdlOptions: {
|
ytdlOptions: {
|
||||||
filter: "audioonly",
|
filter: "audioonly",
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue