Add connection checks for music commands, add a couple more messages, update packages

This commit is contained in:
Essem 2022-10-11 22:36:45 -05:00
parent c5bf373a43
commit 0c08422555
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
12 changed files with 175 additions and 154 deletions

View file

@ -7,6 +7,7 @@ class HostCommand extends MusicCommand {
if (!this.guild) return "This command only works in servers!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!";
if (this.connection.host !== this.author.id && !process.env.OWNER.split(",").includes(this.connection.host)) return "Only the current voice session host can choose another host!";
const input = this.options.user ?? this.args.join(" ");
if (input?.trim()) {

View file

@ -7,6 +7,7 @@ class LoopCommand extends MusicCommand {
if (!this.guild) return "This command only works in servers!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!";
if (this.connection.host !== this.author.id && !this.member.permissions.has("MANAGE_CHANNELS")) return "Only the current voice session host can loop the music!";
const object = this.connection;
object.loop = !object.loop;

View file

@ -7,6 +7,7 @@ class NowPlayingCommand extends MusicCommand {
if (!this.guild) return "This command only works in servers!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!";
const player = this.connection.player;
if (!player) return "I'm not playing anything!";
const track = await player.node.rest.decode(player.track);

View file

@ -12,6 +12,7 @@ class QueueCommand extends MusicCommand {
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (!this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) return "I don't have the `Embed Links` permission!";
const player = this.connection;
if (!player) return "I haven't completely connected yet!";
const node = nodes.filter((val) => val.name === player.player.node.name)[0];
const tracks = await request(`http://${node.url}/decodetracks`, { method: "POST", body: JSON.stringify(this.queue), headers: { authorization: node.auth, "content-type": "application/json" } }).then(res => res.body.json());
const trackList = [];

View file

@ -7,6 +7,7 @@ class RemoveCommand extends MusicCommand {
if (!this.guild) return "This command only works in servers!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!";
if (this.connection.host !== this.author.id && !process.env.OWNER.split(",").includes(this.connection.host)) return "Only the current voice session host can remove songs from the queue!";
const pos = parseInt(this.options.position ?? this.args[0]);
if (isNaN(pos) || pos > this.queue.length || pos < 1) return "That's not a valid position!";

View file

@ -6,6 +6,7 @@ class SeekCommand extends MusicCommand {
if (!this.guild) return "This command only works in servers!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!";
if (this.connection.host !== this.author.id) return "Only the current voice session host can seek the music!";
const player = this.connection.player;
const track = await player.node.rest.decode(player.track);

View file

@ -7,6 +7,7 @@ class ShuffleCommand extends MusicCommand {
if (!this.guild) return "This command only works in servers!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!";
if (this.connection.host !== this.author.id) return "Only the current voice session host can shuffle the music!";
const object = this.connection;
object.shuffle = !object.shuffle;

View file

@ -8,6 +8,7 @@ class SkipCommand extends MusicCommand {
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
const player = this.connection;
if (!player) return "I haven't completely connected yet!";
if (player.host !== this.author.id && !this.member.permissions.has("MANAGE_CHANNELS")) {
const votes = skipVotes.get(this.guild.id) ?? { count: 0, ids: [], max: Math.min(3, player.voiceChannel.voiceMembers.filter((i) => i.id !== this.client.user.id && !i.bot).length) };
if (votes.ids.includes(this.author.id)) return "You've already voted to skip!";

View file

@ -6,6 +6,7 @@ class ToggleCommand extends MusicCommand {
if (!this.guild) return "This command only works in servers!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!";
if (this.connection.host !== this.author.id && !this.member.permissions.has("MANAGE_CHANNELS")) return "Only the current voice session host can pause/resume the music!";
const player = this.connection.player;
player.setPaused(!player.paused ? true : false);