diff --git a/commands/music/pause.js b/commands/music/pause.js index a86556c..d030c66 100644 --- a/commands/music/pause.js +++ b/commands/music/pause.js @@ -7,7 +7,7 @@ class PauseCommand extends MusicCommand { if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!"; if (this.connection.host !== this.message.author.id && !this.message.member.permissions.has("manageChannels")) return "Only the current voice session host can pause/resume the music!"; const player = this.connection.player; - player.pause(!player.paused ? true : false); + await player.pause(!player.paused ? true : false); return `🔊 The player has been ${!player.paused ? "paused" : "resumed"}.`; } @@ -15,4 +15,4 @@ class PauseCommand extends MusicCommand { static aliases = ["resume"]; } -export default PauseCommand; \ No newline at end of file +export default PauseCommand; diff --git a/commands/music/remove.js b/commands/music/remove.js index 7983675..3b94460 100644 --- a/commands/music/remove.js +++ b/commands/music/remove.js @@ -20,4 +20,4 @@ class RemoveCommand extends MusicCommand { static aliases = ["rm"]; } -export default RemoveCommand; \ No newline at end of file +export default RemoveCommand; diff --git a/commands/music/seek.js b/commands/music/seek.js index 108c1ac..2d7e66f 100644 --- a/commands/music/seek.js +++ b/commands/music/seek.js @@ -12,7 +12,7 @@ class SeekCommand extends MusicCommand { if (!track.isSeekable) return "This track isn't seekable!"; const seconds = parseFloat(this.args[0]); if (isNaN(seconds) || (seconds * 1000) > track.length || (seconds * 1000) < 0) return "That's not a valid position!"; - player.seek(seconds * 1000); + await player.seek(seconds * 1000); return `🔊 Seeked track to ${seconds} second(s).`; } @@ -21,4 +21,4 @@ class SeekCommand extends MusicCommand { static arguments = ["[seconds]"]; } -export default SeekCommand; \ No newline at end of file +export default SeekCommand; diff --git a/commands/music/skip.js b/commands/music/skip.js index 75b1bf1..5176de8 100644 --- a/commands/music/skip.js +++ b/commands/music/skip.js @@ -16,14 +16,14 @@ class SkipCommand extends MusicCommand { max: votes.max }; if (votes.count + 1 === votes.max) { - player.player.stop(this.message.channel.guild.id); + await player.player.stop(this.message.channel.guild.id); skipVotes.set(this.message.channel.guild.id, { count: 0, ids: [], max: Math.min(3, player.voiceChannel.voiceMembers.filter((i) => i.id !== this.client.user.id && !i.bot).length) }); } else { skipVotes.set(this.message.channel.guild.id, newObject); return `🔊 Voted to skip song (${votes.count + 1}/${votes.max} people have voted).`; } } else { - player.player.stop(this.message.channel.guild.id); + await player.player.stop(this.message.channel.guild.id); return; } } @@ -32,4 +32,4 @@ class SkipCommand extends MusicCommand { static aliases = ["forceskip"]; } -export default SkipCommand; \ No newline at end of file +export default SkipCommand; diff --git a/commands/music/stop.js b/commands/music/stop.js index e72f5f8..3db6e43 100644 --- a/commands/music/stop.js +++ b/commands/music/stop.js @@ -7,9 +7,9 @@ class StopCommand extends MusicCommand { if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!"; if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!"; if (this.connection.host !== this.message.author.id && !this.message.member.permissions.has("manageChannels")) return "Only the current voice session host can stop the music!"; - manager.leave(this.message.channel.guild.id); + await manager.leave(this.message.channel.guild.id); const connection = this.connection.player; - connection.destroy(); + await connection.destroy(); players.delete(this.message.channel.guild.id); queues.delete(this.message.channel.guild.id); return "🔊 The current voice channel session has ended."; @@ -19,4 +19,4 @@ class StopCommand extends MusicCommand { static aliases = ["disconnect"]; } -export default StopCommand; \ No newline at end of file +export default StopCommand; diff --git a/events/voiceChannelLeave.js b/events/voiceChannelLeave.js index f56be07..c0065c2 100644 --- a/events/voiceChannelLeave.js +++ b/events/voiceChannelLeave.js @@ -7,12 +7,12 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => { const connection = players.get(oldChannel.guild.id); if (connection && oldChannel.id === connection.voiceChannel.id) { if (oldChannel.voiceMembers.filter((i) => i.id !== client.user.id && !i.bot).length === 0) { - connection.player.pause(true); + await connection.player.pause(true); const waitMessage = await client.createMessage(connection.originalChannel.id, "🔊 Waiting 10 seconds for someone to return..."); const awaitRejoin = new AwaitRejoin(oldChannel, true); awaitRejoin.on("end", async (rejoined, member) => { if (rejoined) { - connection.player.pause(false); + await connection.player.pause(false); players.set(connection.voiceChannel.guild.id, { player: connection.player, type: connection.type, host: member.id, voiceChannel: connection.voiceChannel, originalChannel: connection.originalChannel, loop: connection.loop, shuffle: connection.shuffle, playMessage: connection.playMessage }); waitMessage.edit(`🔊 ${member.mention} is the new voice channel host.`); } else { @@ -21,9 +21,9 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => { } catch { // no-op } - connection.player.stop(connection.originalChannel.guild.id); - manager.leave(connection.originalChannel.guild.id); - connection.player.destroy(); + await connection.player.stop(connection.originalChannel.guild.id); + await manager.leave(connection.originalChannel.guild.id); + await connection.player.destroy(); players.delete(connection.originalChannel.guild.id); queues.delete(connection.originalChannel.guild.id); skipVotes.delete(connection.originalChannel.guild.id); @@ -48,9 +48,9 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => { } catch { // no-op } - connection.player.stop(connection.originalChannel.guild.id); - manager.leave(connection.originalChannel.guild.id); - connection.player.destroy(); + await connection.player.stop(connection.originalChannel.guild.id); + await manager.leave(connection.originalChannel.guild.id); + await connection.player.destroy(); players.delete(connection.originalChannel.guild.id); queues.delete(connection.originalChannel.guild.id); skipVotes.delete(connection.originalChannel.guild.id); @@ -63,9 +63,9 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => { } }); } else if (member.id === client.user.id) { - connection.player.stop(connection.originalChannel.guild.id); - manager.leave(connection.originalChannel.guild.id); - connection.player.destroy(); + await connection.player.stop(connection.originalChannel.guild.id); + await manager.leave(connection.originalChannel.guild.id); + await connection.player.destroy(); players.delete(connection.originalChannel.guild.id); queues.delete(connection.originalChannel.guild.id); skipVotes.delete(connection.originalChannel.guild.id); diff --git a/utils/soundplayer.js b/utils/soundplayer.js index 14a3268..b84924e 100644 --- a/utils/soundplayer.js +++ b/utils/soundplayer.js @@ -140,9 +140,9 @@ export async function nextSong(client, message, connection, track, info, music, } catch { // no-op } - manager.leave(voiceChannel.guild.id); + await manager.leave(voiceChannel.guild.id); connection.removeAllListeners("end"); - connection.destroy(); + await connection.destroy(); players.delete(voiceChannel.guild.id); queues.delete(voiceChannel.guild.id); logger.error(error); @@ -181,8 +181,8 @@ export async function nextSong(client, message, connection, track, info, music, // no-op } } else if (process.env.STAYVC !== "true") { - manager.leave(voiceChannel.guild.id); - connection.destroy(); + await manager.leave(voiceChannel.guild.id); + await connection.destroy(); players.delete(voiceChannel.guild.id); queues.delete(voiceChannel.guild.id); skipVotes.delete(voiceChannel.guild.id);