-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New] Added jump command to jump to a certain position in the queue
- Loading branch information
Showing
1 changed file
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" | ||
), | ||
], | ||
}); | ||
} | ||
}, | ||
}; |