Fixed pause message, handle blank names better

This commit is contained in:
Essem 2022-01-05 18:48:08 -06:00
parent e692077ed5
commit 3234688929
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
2 changed files with 30 additions and 26 deletions

View file

@ -8,7 +8,7 @@ class PauseCommand extends MusicCommand {
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!"; 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; const player = this.connection.player;
await player.pause(!player.paused ? true : false); await player.pause(!player.paused ? true : false);
return `🔊 The player has been ${!player.paused ? "paused" : "resumed"}.`; return `🔊 The player has been ${player.paused ? "paused" : "resumed"}.`;
} }
static description = "Pauses/resumes the current song"; static description = "Pauses/resumes the current song";

View file

@ -78,7 +78,7 @@ export async function play(client, sound, message, music = false) {
}); });
if (oldQueue && oldQueue.length !== 0 && music) { if (oldQueue && oldQueue.length !== 0 && music) {
return `Your ${playlistInfo.name ? "playlist" : "tune"} \`${playlistInfo.name ? playlistInfo.name : (tracks[0].info.title !== "" ? tracks[0].info.title : "(blank)")}\` has been added to the queue!`; return `Your ${playlistInfo.name ? "playlist" : "tune"} \`${playlistInfo.name ? playlistInfo.name.trim() : (tracks[0].info.title !== "" ? tracks[0].info.title.trim() : "(blank)")}\` has been added to the queue!`;
} else { } else {
nextSong(client, message, connection, tracks[0].track, tracks[0].info, music, voiceChannel, player ? player.loop : false, player ? player.shuffle : false); nextSong(client, message, connection, tracks[0].track, tracks[0].info, music, voiceChannel, player ? player.loop : false, player ? player.shuffle : false);
return; return;
@ -101,31 +101,35 @@ export async function nextSong(client, message, connection, track, info, music,
if (music && lastTrack === track && players.get(voiceChannel.guild.id)) { if (music && lastTrack === track && players.get(voiceChannel.guild.id)) {
playingMessage = players.get(voiceChannel.guild.id).playMessage; playingMessage = players.get(voiceChannel.guild.id).playMessage;
} else { } else {
playingMessage = await client.createMessage(message.channel.id, !music ? "🔊 Playing sound..." : { try {
embeds: [{ playingMessage = await client.createMessage(message.channel.id, !music ? "🔊 Playing sound..." : {
color: 16711680, embeds: [{
author: { color: 16711680,
name: "Now Playing", author: {
icon_url: client.user.avatarURL name: "Now Playing",
}, icon_url: client.user.avatarURL
fields: [{ },
name: " Title:", fields: [{
value: info.title !== "" ? info.title : "(blank)" name: " Title:",
}, value: info.title && info.title.trim() !== "" ? info.title : "(blank)"
{ },
name: "🎤 Artist:", {
value: info.author !== "" ? info.author : "(blank)" name: "🎤 Artist:",
}, value: info.title && info.author.trim() !== "" ? info.author : "(blank)"
{ },
name: "💬 Channel:", {
value: voiceChannel.name name: "💬 Channel:",
}, value: voiceChannel.name
{ },
name: `${"▬".repeat(parts)}🔘${"▬".repeat(10 - parts)}`, {
value: `0:00/${info.isStream ? "∞" : format(info.length)}` name: `${"▬".repeat(parts)}🔘${"▬".repeat(10 - parts)}`,
value: `0:00/${info.isStream ? "∞" : format(info.length)}`
}]
}] }]
}] });
}); } catch {
// no-op
}
} }
connection.removeAllListeners("error"); connection.removeAllListeners("error");
connection.removeAllListeners("end"); connection.removeAllListeners("end");