diff --git a/commands/music/back.js b/commands/music/back.js index 32d564d..7fea240 100644 --- a/commands/music/back.js +++ b/commands/music/back.js @@ -11,7 +11,7 @@ module.exports = { await interaction.deferReply(); const guildId = interaction.guild.id; - if (!interaction.member.voice.channelId || !global.queue[guildId]) { + if (!interaction.member.voice.channelId || !globalThis.queue[guildId]) { const noValidVCEmbed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.noVC, interaction @@ -20,9 +20,9 @@ module.exports = { return; } - if (global.queue[guildId].voiceChannel) { + if (globalThis.queue[guildId].voiceChannel) { if ( - global.queue[guildId].voiceChannel.id !== + globalThis.queue[guildId].voiceChannel.id !== interaction.member.voice.channelId ) { const differentVCEmbed = createMessageEmbed( @@ -34,7 +34,7 @@ module.exports = { } } - if (global.queue[guildId].queue.length === 0) { + if (globalThis.queue[guildId].queue.length === 0) { const noMusicEmbed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.noMusic, interaction @@ -43,25 +43,26 @@ module.exports = { return; } - const index = global.queue[guildId].index - 1; - global.queue[guildId].previous = - global.queue[guildId].queue[global.queue[guildId].index]; + const index = globalThis.queue[guildId].index - 1; + globalThis.queue[guildId].previous = + globalThis.queue[guildId].queue[globalThis.queue[guildId].index]; if (index < 0) { const embed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.noMoreToBack ); - global.queue[guildId].textChannel.send({ embeds: [embed] }); + globalThis.queue[guildId].textChannel.send({ embeds: [embed] }); return; } - global.queue[guildId].index--; - global.queue[guildId].suppressEnd = true; - global.queue[guildId].player.position = 0; - global.queue[guildId].player.play({ + globalThis.queue[guildId].index--; + globalThis.queue[guildId].suppressEnd = true; + globalThis.queue[guildId].player.position = 0; + globalThis.queue[guildId].player.play({ track: { encoded: - global.queue[guildId].queue[global.queue[guildId].index].data.encoded, + globalThis.queue[guildId].queue[globalThis.queue[guildId].index].data + .encoded, }, }); diff --git a/commands/music/pause.js b/commands/music/pause.js index 419ac76..c4ca184 100644 --- a/commands/music/pause.js +++ b/commands/music/pause.js @@ -20,7 +20,7 @@ module.exports = { await interaction.deferReply(); const guildId = interaction.guild.id; - if (!interaction.member.voice.channelId || !global.queue[guildId]) { + if (!interaction.member.voice.channelId || !globalThis.queue[guildId]) { const noValidVCEmbed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.noVC, interaction @@ -29,9 +29,9 @@ module.exports = { return; } - if (global.queue[guildId].voiceChannel) { + if (globalThis.queue[guildId].voiceChannel) { if ( - global.queue[guildId].voiceChannel.id !== + globalThis.queue[guildId].voiceChannel.id !== interaction.member.voice.channelId ) { const differentVCEmbed = createMessageEmbed( @@ -54,10 +54,11 @@ module.exports = { await interaction.editReply({ embeds: [invalidTimeEmbed] }); return; } - await global.queue[guildId].player.get(); + await globalThis.queue[guildId].player.get(); if ( seconds > - global.queue[guildId].queue[global.queue[guildId].index].data.info.length + globalThis.queue[guildId].queue[globalThis.queue[guildId].index].data.info + .length ) { const embed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.outOfLength, @@ -66,7 +67,7 @@ module.exports = { await interaction.editReply({ embeds: [embed] }); return; } - global.queue[guildId].player.seek(seconds * 1000); + globalThis.queue[guildId].player.seek(seconds * 1000); const embed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.seeked.replace('{time}', time), interaction diff --git a/commands/music/play.js b/commands/music/play.js index fa5e4a6..86b1831 100644 --- a/commands/music/play.js +++ b/commands/music/play.js @@ -1,14 +1,20 @@ const config = require('../../config.json'); +const fs = require('node:fs'); + const { getLocale } = require('../../lang/lang.js'); const { createMessageEmbed } = require('../../util/embed.js'); const guilds = require('../../data/guilds.json'); +const cache = require('../../cache/search.json'); +const searchResultCache = require('../../cache/searchResults.json'); const discord = require('discord.js'); const { SlashCommandBuilder } = require('discord.js'); const listenEvents = require('../../util/playerEvent.js'); +const log = require('../../util/log.js'); + module.exports = { data: new SlashCommandBuilder() .setName('play') @@ -21,45 +27,100 @@ module.exports = { .setRequired(false) ), async autocomplete(interaction) { - const query = interaction.options.getString('query'); - if (!query) { - return { - suggestions: [ - { - name: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', - value: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', - }, - ], - }; + const focusedValue = interaction.options.getFocused(); + log.info(`${focusedValue} is focused.`, false, true); + if (searchResultCache[focusedValue]) { + const list = []; + for ( + let i = 0; + i < 5 && i < searchResultCache[focusedValue].data.length; + i++ + ) { + list.push(searchResultCache[focusedValue].data[i].info.title); + } + await interaction.respond( + list.map((choice) => ({ + name: choice, + value: choice, + })) + ); + return; } - const result = await global.queue[interaction.guild.id].node.loadTracks( - `ytsearch:${query}` - ); - if (!result?.data.length) { - return { - suggestions: [ - { - name: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', - value: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', - }, - ], - }; + + const node = globalThis.Tsumi.getIdealNode(); + + const result = await node.loadTracks(focusedValue); + + switch (result.loadType) { + case 'empty': { + const searchResult = await node.loadTracks(`ytsearch:${focusedValue}`); + if (!searchResult?.data.length) return; + + searchResultCache[focusedValue] = searchResult; + const list = []; + for (let i = 0; i < 5 && i < searchResult.data.length; i++) { + list.push(searchResult.data[i]); + } + await interaction.respond( + list.map((choice) => ({ + name: choice.info.title, + value: choice.info.title, + })) + ); + searchResultCache[focusedValue].data = list; + fs.writeFileSync( + './cache/searchResults.json', + JSON.stringify(searchResultCache) + ); + break; + } + case 'track': { + const list = [result.data.info.title]; + await interaction.respond( + list.map((choice) => ({ name: choice, value: result.encoded })) + ); + break; + } + case 'playlist': { + const list = []; + for (let i = 0; i < 25 && i < result.data.tracks.length; i++) { + list.push([ + result.data.tracks[i].info.title, + result.data.tracks[i].info.title, + ]); + } + + await interaction.respond( + list.map((choice) => ({ name: choice[0], value: choice[1] })) + ); + + break; + } + case 'search': { + if (!result?.data.length) return; + + const list = []; + for (let i = 0; i < 5 && i < result.data.length; i++) { + list.push(result.data[i].info.title, result.data[i].info.title); + } + + await interaction.respond( + list.map((choice) => ({ name: choice, value: choice })) + ); + break; + } + case 'error': { + log.error('An error has occured while trying to search for a track.'); + } } - const suggestions = result.data.map((track) => ({ - name: track.info.title, - value: track.info.uri, - })); - return { suggestions }; }, async execute(interaction) { - await interaction.deferReply(); - const guildId = interaction.guild.id; //Add guild queue to the global queue and node - if (!global.queue[interaction.guild.id]) { - global.queue.add(interaction.guild.id); - global.queue[guildId].node = global.Tsumi.getIdealNode(); + if (!globalThis.queue[interaction.guild.id]) { + globalThis.queue.add(interaction.guild.id); + globalThis.queue[guildId].node = globalThis.Tsumi.getIdealNode(); } // Check if the user is in a voice channel @@ -68,20 +129,20 @@ module.exports = { getLocale(guilds[guildId].locale).vc.noVC, interaction ); - await interaction.editReply({ embeds: [noValidVCEmbed] }); + await interaction.reply({ embeds: [noValidVCEmbed] }); return; } - if (global.queue[guildId].voiceChannel) { + if (globalThis.queue[guildId].voiceChannel) { if ( - global.queue[guildId].voiceChannel.id !== + globalThis.queue[guildId].voiceChannel.id !== interaction.member.voice.channelId ) { const differentVCEmbed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.differentVC, interaction ); - await interaction.editReply({ embeds: [differentVCEmbed] }); + await interaction.reply({ embeds: [differentVCEmbed] }); return; } } @@ -89,10 +150,10 @@ module.exports = { const query = interaction.options.getString('query'); //Join channel first - if (!global.queue[guildId].voiceChannel) { - global.queue[guildId].textChannel = interaction.channel; - global.queue[guildId].voiceChannel = interaction.member.voice.channel; - global.queue[guildId].player = await global.queue[ + if (!globalThis.queue[guildId].voiceChannel) { + globalThis.queue[guildId].textChannel = interaction.channel; + globalThis.queue[guildId].voiceChannel = interaction.member.voice.channel; + globalThis.queue[guildId].player = await globalThis.queue[ guildId ].node.joinVoiceChannel({ guildId: guildId, @@ -106,12 +167,12 @@ module.exports = { } //そもそもVCに未参加 - if (!query && global.queue[guildId].isEmpty()) { + if (!query && globalThis.queue[guildId].isEmpty()) { const noQueryEmbed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.joined, interaction ); - await interaction.editReply({ embeds: [noQueryEmbed] }); + await interaction.reply({ embeds: [noQueryEmbed] }); return; } @@ -124,12 +185,12 @@ module.exports = { */ // クエリが無いがキューは空ではない - if (!query && !global.queue[guildId].isEmpty()) { + if (!query && !globalThis.queue[guildId].isEmpty()) { // Start playing the queue return; } - const result = await global.queue[guildId].node.loadTracks(query); + const result = await globalThis.queue[guildId].node.loadTracks(query); let res = null; switch (result.loadType) { @@ -138,19 +199,27 @@ module.exports = { break; } case 'empty': { - const searchResult = await global.queue[guildId].node.loadTracks( + if (cache[query]) { + res = cache[query].res; + break; + } + const searchResult = await globalThis.queue[guildId].node.loadTracks( `ytsearch:${query}` ); if (!searchResult?.data.length) { - await interaction.editReply('Sorry, I could not find any data.'); + await interaction.reply('Sorry, I could not find any data.'); return; } res = searchResult.data.shift(); + cache[query] = { + res, + time: new Date(), + }; break; } case 'playlist': { result.data.tracks.forEach((track) => { - global.queue[guildId].add(track, interaction.user); + globalThis.queue[guildId].add(track, interaction.user); }); const resultEmbed = new discord.EmbedBuilder() .setColor(config.config.color.info) @@ -159,9 +228,8 @@ module.exports = { iconURL: interaction.user.avatarURL(), }); - await interaction.editReply({ embeds: [resultEmbed] }); - if (global.queue[guildId].player.status === 'playing') return; - // start playing the queue + await interaction.reply({ embeds: [resultEmbed] }); + if (globalThis.queue[guildId].player.status === 'playing') return; return; } case 'search': { @@ -177,7 +245,7 @@ module.exports = { return; } } - global.queue[guildId].queue.push({ + globalThis.queue[guildId].queue.push({ data: res, user: interaction.user, }); @@ -189,13 +257,14 @@ module.exports = { iconURL: interaction.user.avatarURL(), }); - await interaction.editReply({ embeds: [resultEmbed] }); - if (global.queue[guildId].player.status === 'playing') return; - await global.queue[guildId].player.play({ + await interaction.reply({ embeds: [resultEmbed] }); + if (globalThis.queue[guildId].player.status === 'playing') return; + await globalThis.queue[guildId].player.play({ track: { encoded: - global.queue[guildId].queue[global.queue[guildId].index].data.encoded, + globalThis.queue[guildId].queue[globalThis.queue[guildId].index].data.encoded, }, }); + fs.writeFileSync('./cache/search.json', JSON.stringify(cache)); }, }; diff --git a/commands/music/queue.js b/commands/music/queue.js index 5b169d9..0dc9f08 100644 --- a/commands/music/queue.js +++ b/commands/music/queue.js @@ -33,7 +33,7 @@ module.exports = { await interaction.deferReply(); const guildId = interaction.guild.id; - if (!interaction.member.voice.channelId || !global.queue[guildId]) { + if (!interaction.member.voice.channelId || !globalThis.queue[guildId]) { const noValidVCEmbed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.noVC, interaction @@ -42,9 +42,9 @@ module.exports = { return; } - if (global.queue[guildId].voiceChannel) { + if (globalThis.queue[guildId].voiceChannel) { if ( - global.queue[guildId].voiceChannel.id !== + globalThis.queue[guildId].voiceChannel.id !== interaction.member.voice.channelId ) { const differentVCEmbed = createMessageEmbed( @@ -61,7 +61,7 @@ module.exports = { case 'show': // Show the current queue let content = ''; - if (global.queue[guildId].queue.length === 0) { + if (globalThis.queue[guildId].queue.length === 0) { const embed = new EmbedBuilder() .setColor(config.config.color.info) .setTitle('Queue') @@ -69,11 +69,11 @@ module.exports = { await interaction.editReply({ embeds: [embed] }); } else { content += `📀 ${ - global.queue[guildId].queue[global.queue[guildId].index].data.info + globalThis.queue[guildId].queue[globalThis.queue[guildId].index].data.info .title }`; - global.queue[guildId].queue.forEach((item, i) => { + globalThis.queue[guildId].queue.forEach((item, i) => { content += `\n${i + 1}: ${item.data.info.title}`; }); const embed = new EmbedBuilder() diff --git a/commands/music/seek.js b/commands/music/seek.js index 3c964df..ca07379 100644 --- a/commands/music/seek.js +++ b/commands/music/seek.js @@ -17,7 +17,7 @@ module.exports = { await interaction.deferReply(); const guildId = interaction.guild.id; - if (!interaction.member.voice.channelId || !global.queue[guildId]) { + if (!interaction.member.voice.channelId || !globalThis.queue[guildId]) { const noValidVCEmbed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.noVC, interaction @@ -26,9 +26,9 @@ module.exports = { return; } - if (global.queue[guildId].voiceChannel) { + if (globalThis.queue[guildId].voiceChannel) { if ( - global.queue[guildId].voiceChannel.id !== + globalThis.queue[guildId].voiceChannel.id !== interaction.member.voice.channelId ) { const differentVCEmbed = createMessageEmbed( @@ -51,10 +51,10 @@ module.exports = { await interaction.editReply({ embeds: [invalidTimeEmbed] }); return; } - await global.queue[guildId].player.get(); + await globalThis.queue[guildId].player.get(); if ( seconds > - global.queue[guildId].queue[global.queue[guildId].index].data.info.length + globalThis.queue[guildId].queue[globalThis.queue[guildId].index].data.info.length ) { const embed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.outOfLength, @@ -63,7 +63,7 @@ module.exports = { await interaction.editReply({ embeds: [embed] }); return; } - global.queue[guildId].player.seek(seconds * 1000); + globalThis.queue[guildId].player.seek(seconds * 1000); const embed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.seeked.replace('{time}', time), interaction diff --git a/commands/music/skip.js b/commands/music/skip.js index c14cee1..73bd30d 100644 --- a/commands/music/skip.js +++ b/commands/music/skip.js @@ -11,7 +11,7 @@ module.exports = { await interaction.deferReply(); const guildId = interaction.guild.id; - if (!interaction.member.voice.channelId || !global.queue[guildId]) { + if (!interaction.member.voice.channelId || !globalThis.queue[guildId]) { const noValidVCEmbed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.noVC, interaction @@ -20,9 +20,9 @@ module.exports = { return; } - if (global.queue[guildId].voiceChannel) { + if (globalThis.queue[guildId].voiceChannel) { if ( - global.queue[guildId].voiceChannel.id !== + globalThis.queue[guildId].voiceChannel.id !== interaction.member.voice.channelId ) { const differentVCEmbed = createMessageEmbed( @@ -34,7 +34,7 @@ module.exports = { } } - if (global.queue[guildId].queue.length === 0) { + if (globalThis.queue[guildId].queue.length === 0) { const noMusicEmbed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.noMusic, interaction @@ -43,25 +43,26 @@ module.exports = { return; } - const index = global.queue[guildId].index + 1; - global.queue[guildId].previous = - global.queue[guildId].queue[global.queue[guildId].index]; + const index = globalThis.queue[guildId].index + 1; + globalThis.queue[guildId].previous = + globalThis.queue[guildId].queue[globalThis.queue[guildId].index]; - if (index >= global.queue[guildId].queue.length) { + if (index >= globalThis.queue[guildId].queue.length) { const embed = createMessageEmbed( getLocale(guilds[guildId].locale).vc.noMoreToSkip ); - global.queue[guildId].textChannel.send({ embeds: [embed] }); + globalThis.queue[guildId].textChannel.send({ embeds: [embed] }); return; } - global.queue[guildId].index++; - global.queue[guildId].suppressEnd = true; - global.queue[guildId].player.position = 0; - global.queue[guildId].player.play({ + globalThis.queue[guildId].index++; + globalThis.queue[guildId].suppressEnd = true; + globalThis.queue[guildId].player.position = 0; + globalThis.queue[guildId].player.play({ track: { encoded: - global.queue[guildId].queue[global.queue[guildId].index].data.encoded, + globalThis.queue[guildId].queue[globalThis.queue[guildId].index].data + .encoded, }, }); diff --git a/events/ready.js b/events/ready.js index 1a35da7..afe071d 100644 --- a/events/ready.js +++ b/events/ready.js @@ -7,13 +7,9 @@ module.exports = { name: Events.ClientReady, once: true, execute(client) { - log.info( - `Logged in as ${client.user.tag}`, - true, - config.config.log.saveToFile - ); + log.info(`Logged in as ${client.user.tag}`, true, config.config.log.saveToFile); config.nodes.forEach((node) => { - global.Tsumi.addNode(node); + globalThis.Tsumi.addNode(node); }); }, }; diff --git a/index.js b/index.js index 5bb223a..3282e2c 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ const path = require('node:path'); const log = require('./util/log.js'); const { playerQueue } = require('./util/queue.js'); -global.queue = new playerQueue(); +globalThis.queue = new playerQueue(); const discord = require('discord.js'); const { TsumiInstance } = require('tsumi'); @@ -42,11 +42,11 @@ const client = new discord.Client({ ], }); -global.discordClient = client; -global.Tsumi = new TsumiInstance({ +globalThis.discordClient = client; +globalThis.Tsumi = new TsumiInstance({ botId: config.bot.applicationId, sendPayload: (guildId, payload) => { - global.discordClient.guilds.cache.get(guildId).shard.send(payload); + globalThis.discordClient.guilds.cache.get(guildId).shard.send(payload); }, userAgent: 'Swallow/0.0.2', }); @@ -57,9 +57,7 @@ const foldersPath = path.join(__dirname, 'commands'); const commandFolders = fs.readdirSync(foldersPath); const eventsPath = path.join(__dirname, 'events'); -const eventFiles = fs - .readdirSync(eventsPath) - .filter((file) => file.endsWith('.js')); +const eventFiles = fs.readdirSync(eventsPath).filter((file) => file.endsWith('.js')); for (const folder of commandFolders) { const commandsPath = path.join(foldersPath, folder); @@ -91,12 +89,12 @@ for (const file of eventFiles) { } } -global.Tsumi.on('ready', () => { +globalThis.Tsumi.on('ready', () => { log.info('Tsumi is ready', true, config.config.log.saveToFile); }); client.on('raw', (data) => { - global.Tsumi.handleRaw(data); + globalThis.Tsumi.handleRaw(data); }); client.login(config.bot.token); diff --git a/util/embed.js b/util/embed.js index 7e5e7a3..7b1f4cf 100644 --- a/util/embed.js +++ b/util/embed.js @@ -20,19 +20,19 @@ function createMessageEmbed(content, interaction) { } async function createMusicEmbed(guildId, mode, type) { - const current = global.queue[guildId].queue[global.queue[guildId].index].data.info; + const current = globalThis.queue[guildId].queue[globalThis.queue[guildId].index].data.info; let requester = ''; if ( - global.queue[guildId].queue[global.queue[guildId].index].user === + globalThis.queue[guildId].queue[globalThis.queue[guildId].index].user === 'Auto Recommendation' ) { requester = 'Auto Recommendation'; } else { requester = `<@${ - global.queue[guildId].queue[global.queue[guildId].index].user.id + globalThis.queue[guildId].queue[globalThis.queue[guildId].index].user.id }>`; } - await global.queue[guildId].player.get(); + await globalThis.queue[guildId].player.get(); const embed = new EmbedBuilder() .setColor(config.config?.color?.info || '#000000') .addFields( @@ -49,7 +49,7 @@ async function createMusicEmbed(guildId, mode, type) { { name: 'Duration', value: `${formatTime( - Math.floor(global.queue[guildId].player.position / 1000) + Math.floor(globalThis.queue[guildId].player.position / 1000) )}/${formatTime(Math.floor(current.length / 1000))}`, inline: true, }, @@ -60,13 +60,13 @@ async function createMusicEmbed(guildId, mode, type) { }, { name: 'Volume', - value: `${global.queue[guildId].volume}%`, + value: `${globalThis.queue[guildId].volume}%`, inline: true, }, { name: 'Position', - value: `${global.queue[guildId].index + 1}/${ - global.queue[guildId].queue.length + value: `${globalThis.queue[guildId].index + 1}/${ + globalThis.queue[guildId].queue.length }`, inline: true, } diff --git a/util/playerEvent.js b/util/playerEvent.js index 7b20f09..fa07878 100644 --- a/util/playerEvent.js +++ b/util/playerEvent.js @@ -5,39 +5,39 @@ const guilds = require('../data/guilds.json'); const { createMusicEmbed, createMessageEmbed, createButton } = require('./embed.js'); const listenEvents = async (guildId) => { - global.queue[guildId].player.on('start', async () => { - global.queue[guildId].player.status = 'playing'; - global.queue[guildId].suppressEnd = false; + globalThis.queue[guildId].player.on('start', async () => { + globalThis.queue[guildId].player.status = 'playing'; + globalThis.queue[guildId].suppressEnd = false; const embed = await createMusicEmbed(guildId, 'Start'); - if (global.queue[guildId].panel) global.queue[guildId].panel.delete(); - global.queue[guildId].panel = await global.queue[guildId].textChannel.send({ + if (globalThis.queue[guildId].panel) globalThis.queue[guildId].panel.delete(); + globalThis.queue[guildId].panel = await globalThis.queue[guildId].textChannel.send({ embeds: [embed], components: createButton(), }); }); - global.queue[guildId].player.on('end', async (data) => { + globalThis.queue[guildId].player.on('end', async (data) => { if (queue[guildId].suppressEnd) return; - const index = global.queue[guildId].index + 1; - global.queue[guildId].previous = - global.queue[guildId].queue[global.queue[guildId].index]; - global.queue[guildId].player.status = 'finished'; - if (index >= global.queue[guildId].queue.length) { - if (global.queue[guildId].autoReplay) { + const index = globalThis.queue[guildId].index + 1; + globalThis.queue[guildId].previous = + globalThis.queue[guildId].queue[globalThis.queue[guildId].index]; + globalThis.queue[guildId].player.status = 'finished'; + if (index >= globalThis.queue[guildId].queue.length) { + if (globalThis.queue[guildId].autoReplay) { //Do replay things - } else if (global.queue[guildId].autoPlay) { + } else if (globalThis.queue[guildId].autoPlay) { //Do auto play stuff here } else { const embed = createMessageEmbed( getLocale(guilds[guildId]).vc.queueEnded ); - global.queue[guildId].textChannel.send({ embeds: [embed] }); + globalThis.queue[guildId].textChannel.send({ embeds: [embed] }); } } else { - global.queue[guildId].index++; - global.queue[guildId].player.play({ + globalThis.queue[guildId].index++; + globalThis.queue[guildId].player.play({ track: { encoded: - global.queue[guildId].queue[global.queue[guildId].index].data + globalThis.queue[guildId].queue[globalThis.queue[guildId].index].data .encoded, }, });