From 046b1d7f285a115c4120622f672a01e9d5a05d6f Mon Sep 17 00:00:00 2001 From: Essem Date: Sat, 11 Jun 2022 15:23:41 -0500 Subject: [PATCH] Fix a couple of sound player bugs --- classes/musicCommand.js | 2 +- utils/soundplayer.js | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/classes/musicCommand.js b/classes/musicCommand.js index 3715786..847f441 100644 --- a/classes/musicCommand.js +++ b/classes/musicCommand.js @@ -4,7 +4,7 @@ import { players, queues } from "../utils/soundplayer.js"; class MusicCommand extends Command { constructor(client, cluster, worker, ipc, options) { super(client, cluster, worker, ipc, options); - if (this.channel) { + if (this.channel.guild) { this.connection = players.get(this.channel.guild.id); this.queue = queues.get(this.channel.guild.id); } diff --git a/utils/soundplayer.js b/utils/soundplayer.js index 9e9fb1e..5cece6f 100644 --- a/utils/soundplayer.js +++ b/utils/soundplayer.js @@ -152,7 +152,6 @@ export async function nextSong(client, options, connection, track, info, music, connection.removeAllListeners("error"); connection.removeAllListeners("end"); await connection.play(track); - await connection.volume(75); players.set(voiceChannel.guild.id, { player: connection, type: music ? "music" : "sound", host: host, voiceChannel: voiceChannel, originalChannel: options.channel, loop: loop, shuffle: shuffle, playMessage: playingMessage }); connection.once("error", async (error) => { try { @@ -172,7 +171,12 @@ export async function nextSong(client, options, connection, track, info, music, players.delete(voiceChannel.guild.id); queues.delete(voiceChannel.guild.id); logger.error(error); - await (options.type === "classic" ? options.channel.createMessage : options.interaction.createMessage)(`🔊 Looks like there was an error regarding sound playback:\n\`\`\`${error.type}: ${error.error}\`\`\``); + const content = `🔊 Looks like there was an error regarding sound playback:\n\`\`\`${error.type}: ${error.error}\`\`\``; + if (options.type === "classic") { + await client.createMessage(options.channel.id, content); + } else { + await options.interaction.createMessage(content); + } }); connection.on("end", async (data) => { if (data.reason === "REPLACED") return; @@ -213,7 +217,12 @@ export async function nextSong(client, options, connection, track, info, music, players.delete(voiceChannel.guild.id); queues.delete(voiceChannel.guild.id); skipVotes.delete(voiceChannel.guild.id); - if (music) await (options.type === "classic" ? options.channel.createMessage : options.interaction.createMessage)("🔊 The current voice channel session has ended."); + const content = "🔊 The current voice channel session has ended."; + if (options.type === "classic") { + await client.createMessage(options.channel.id, content); + } else { + await options.interaction.createMessage(content); + } try { if (playingMessage.channel.messages.has(playingMessage.id)) await playingMessage.delete(); if (player && player.playMessage.channel.messages.has(player.playMessage.id)) await player.playMessage.delete();