From b07c0e389e043e1514c8f3f00351530ec9bf706e Mon Sep 17 00:00:00 2001 From: Essem Date: Sun, 19 Sep 2021 18:06:09 -0500 Subject: [PATCH] Added forceskip, fixed blank title tracks some more --- commands/music/forceskip.js | 18 ++++++++++++++++++ commands/music/queue.js | 4 ++-- utils/soundplayer.js | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 commands/music/forceskip.js diff --git a/commands/music/forceskip.js b/commands/music/forceskip.js new file mode 100644 index 0000000..668c523 --- /dev/null +++ b/commands/music/forceskip.js @@ -0,0 +1,18 @@ +import { skipVotes } from "../../utils/soundplayer.js"; +import MusicCommand from "../../classes/musicCommand.js"; + +class ForceSkipCommand extends MusicCommand { + async run() { + if (!this.message.channel.guild) return "This command only works in servers!"; + 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.message.member.permissions.has("manageChannels")) return "You need to have the `Manage Channels` permission to force skip!"; + this.connection.player.stop(this.message.channel.guild.id); + skipVotes.set(this.message.channel.guild.id, { count: 0, ids: [], max: Math.min(3, this.connection.voiceChannel.voiceMembers.size - 1) }); + return; + } + + static description = "Force skips the current song"; +} + +export default ForceSkipCommand; \ No newline at end of file diff --git a/commands/music/queue.js b/commands/music/queue.js index 7c3a97c..44da305 100644 --- a/commands/music/queue.js +++ b/commands/music/queue.js @@ -18,7 +18,7 @@ class QueueCommand extends MusicCommand { const trackList = []; const firstTrack = tracks.shift(); for (const [i, track] of tracks.entries()) { - trackList.push(`${i + 1}. ${track.info.author} - **${track.info.title}** (${track.info.isStream ? "∞" : format(track.info.length)})`); + trackList.push(`${i + 1}. ${track.info.author !== "" ? track.info.author : "(blank)"} - **${track.info.title !== "" ? track.info.title : "(blank)"}** (${track.info.isStream ? "∞" : format(track.info.length)})`); } const pageSize = 5; const embeds = []; @@ -39,7 +39,7 @@ class QueueCommand extends MusicCommand { }, "fields": [{ "name": "🎶 Now Playing", - "value": `${firstTrack.info.author} - **${firstTrack.info.title}** (${firstTrack.info.isStream ? "∞" : format(firstTrack.info.length)})` + "value": `${firstTrack.info.author !== "" ? firstTrack.info.author : "(blank)"} - **${firstTrack.info.title !== "" ? firstTrack.info.title : "(blank)"}** (${firstTrack.info.isStream ? "∞" : format(firstTrack.info.length)})` }, { "name": "🔁 Looping?", "value": player.loop ? "Yes" : "No" diff --git a/utils/soundplayer.js b/utils/soundplayer.js index 118754d..5592a5f 100644 --- a/utils/soundplayer.js +++ b/utils/soundplayer.js @@ -78,7 +78,7 @@ export async function play(client, sound, message, music = false) { }); if (oldQueue && music) { - return `Your ${playlistInfo.name ? "playlist" : "tune"} \`${playlistInfo.name ? playlistInfo.name : tracks[0].info.title}\` has been added to the queue!`; + 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!`; } else { nextSong(client, message, connection, tracks[0].track, tracks[0].info, music, voiceChannel, player ? player.loop : false); return;