Fixed pagination issues, merged forceskip into skip
This commit is contained in:
parent
d0d1f63add
commit
636857e20f
3 changed files with 5 additions and 23 deletions
|
@ -1,18 +0,0 @@
|
||||||
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.filter((i) => i.id !== this.client.user.id && !i.bot).length) });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static description = "Force skips the current song";
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ForceSkipCommand;
|
|
|
@ -7,7 +7,7 @@ class SkipCommand extends MusicCommand {
|
||||||
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
|
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.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||||
const player = this.connection;
|
const player = this.connection;
|
||||||
if (player.host !== this.message.author.id) {
|
if (player.host !== this.message.author.id && !this.message.member.permissions.has("manageChannels")) {
|
||||||
const votes = skipVotes.has(this.message.channel.guild.id) ? skipVotes.get(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) };
|
const votes = skipVotes.has(this.message.channel.guild.id) ? skipVotes.get(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) };
|
||||||
if (votes.ids.includes(this.message.author.id)) return "You've already voted to skip!";
|
if (votes.ids.includes(this.message.author.id)) return "You've already voted to skip!";
|
||||||
const newObject = {
|
const newObject = {
|
||||||
|
@ -29,6 +29,7 @@ class SkipCommand extends MusicCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
static description = "Skips the current song";
|
static description = "Skips the current song";
|
||||||
|
static aliases = ["forceskip"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SkipCommand;
|
export default SkipCommand;
|
|
@ -79,12 +79,12 @@ export default async (client, message, pages, timeout = 120000) => {
|
||||||
case "back":
|
case "back":
|
||||||
await fetch(`https://discord.com/api/v8/interactions/${id}/${token}/callback`, ackOptions);
|
await fetch(`https://discord.com/api/v8/interactions/${id}/${token}/callback`, ackOptions);
|
||||||
page = page > 0 ? --page : pages.length - 1;
|
page = page > 0 ? --page : pages.length - 1;
|
||||||
currentPage = await currentPage.edit(pages[page]);
|
currentPage = await currentPage.edit(Object.assign(pages[page], options));
|
||||||
break;
|
break;
|
||||||
case "forward":
|
case "forward":
|
||||||
await fetch(`https://discord.com/api/v8/interactions/${id}/${token}/callback`, ackOptions);
|
await fetch(`https://discord.com/api/v8/interactions/${id}/${token}/callback`, ackOptions);
|
||||||
page = page + 1 < pages.length ? ++page : 0;
|
page = page + 1 < pages.length ? ++page : 0;
|
||||||
currentPage = await currentPage.edit(pages[page]);
|
currentPage = await currentPage.edit(Object.assign(pages[page], options));
|
||||||
break;
|
break;
|
||||||
case "jump":
|
case "jump":
|
||||||
await fetch(`https://discord.com/api/v8/interactions/${id}/${token}/callback`, ackOptions);
|
await fetch(`https://discord.com/api/v8/interactions/${id}/${token}/callback`, ackOptions);
|
||||||
|
@ -107,7 +107,7 @@ export default async (client, message, pages, timeout = 120000) => {
|
||||||
if (await client.getMessage(askMessage.channel.id, askMessage.id).catch(() => undefined)) askMessage.delete();
|
if (await client.getMessage(askMessage.channel.id, askMessage.id).catch(() => undefined)) askMessage.delete();
|
||||||
if (manageMessages) await response.delete();
|
if (manageMessages) await response.delete();
|
||||||
page = Number(response.content) - 1;
|
page = Number(response.content) - 1;
|
||||||
currentPage = await currentPage.edit(pages[page]);
|
currentPage = await currentPage.edit(Object.assign(pages[page], options));
|
||||||
});
|
});
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -127,5 +127,4 @@ export default async (client, message, pages, timeout = 120000) => {
|
||||||
interactionCollector.removeAllListeners("interaction");
|
interactionCollector.removeAllListeners("interaction");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return currentPage;
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue