Skip to content

Commit

Permalink
[New] Added jump command to jump to a certain position in the queue
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Nov 2, 2021
1 parent 929d7e7 commit 76f2d5a
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions commands/Music/jump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { embedMessage } = require("../../modules/embedSimple");

module.exports = {
name: "jump",
args: true,
description: "Jumps to a particular position in the queue",
usage: "jump <position>",
async run(message, args, client) {
const queue = client.player.getQueue(message.guild);

if (!queue || !queue.playing)
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`❌ | There is nothing playing at the moment`
),
],
});

if (!args[0])
return await message.channel.send({
embeds: [
embedMessage("#9dcc37", `Please provide the position to jump`),
],
});
try {
if (queue) {
await queue.jump(Number(args[0]));
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`✅ jumped to position ${args[0]} in the queue!`
),
],
});
}
} catch (err) {
client.logger(err.message, "error");
await message.channel.send({
embeds: [embedMessage("#9dcc37", "Could not jump to this position")],
});
}
},
data: new SlashCommandBuilder()
.setName("jump")
.setDescription("Jumps to a particular position in the queue")
.addIntegerOption((option) =>
option
.setName("position")
.setDescription("new position")
.setRequired(true)
),
async execute(interaction, client) {
await interaction.deferReply();
const queue = client.player.getQueue(interaction.guild);
const position = interaction.options.getInteger("position");
if (!queue || !queue.playing)
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`❌ | There is nothing playing at the moment`
),
],
});

try {
if (queue) {
await queue.jump(Number(position));
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`✅ Jumped to position ${position} in the queue!`
),
],
});
}
} catch (err) {
client.logger(err.message, "error");
await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
"Could not jump to this position because it does not exist!"
),
],
});
}
},
};

0 comments on commit 76f2d5a

Please sign in to comment.