mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 22:16:13 +00:00
feat: Added common logic for validating command execution
This commit is contained in:
1 parent
780d6f4de3
commit
c7400f9fcd
16 files changed
+155
-244
No files matched your search
@@ -0,0 +1,36 @@
|
||||
const { embedOptions } = require('../../config');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
exports.queueDoesNotExist = async (interaction, queue) => {
|
||||
if (!queue) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nThere are no tracks in the queue and nothing currently playing. First add some tracks with **\`/play\`**!`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.queueNoCurrentTrack = async (interaction, queue) => {
|
||||
if (!queue.currentTrack) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nThere is nothing currently playing. First add some tracks with **\`/play\`**!`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
const { embedOptions, systemOptions } = require('../../config');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
exports.notValidGuildId = async (interaction) => {
|
||||
if (!systemOptions.systemGuildIds.includes(interaction.guildId)) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nNo permission to execute this command.\n\nThe command \`${interaction.commandName}\` cannot be executed in this server.`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
const { embedOptions } = require('../../config');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
exports.notInVoiceChannel = async (interaction) => {
|
||||
if (!interaction.member.voice.channel) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.warning} Oops!**\nYou need to be in a voice channel to use this command.`
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
Reference in new issue
Block a user