Skip to content

Commit

Permalink
chore: Update global references to use globalThis
Browse files Browse the repository at this point in the history
This commit updates the code to use `globalThis` instead of `global` for global references. This change ensures compatibility across different JavaScript environments and avoids potential conflicts with other libraries or frameworks.

Note: The commit message has been generated based on the provided code changes and recent repository commits.
  • Loading branch information
Fyphen1223 committed May 16, 2024
1 parent 6be47d2 commit d6b7c02
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 140 deletions.
27 changes: 14 additions & 13 deletions commands/music/back.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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
Expand All @@ -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,
},
});

Expand Down
13 changes: 7 additions & 6 deletions commands/music/pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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,
Expand All @@ -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
Expand Down
Loading

0 comments on commit d6b7c02

Please sign in to comment.