feat: Added common logic for validating command execution

This commit is contained in:
Marius Begby committed 2023-07-18 14:53:07 +02:00
1 parent 780d6f4de3
commit c7400f9fcd
16 files changed
+155 -244

No files matched your search

+36
View File
@@ -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;
};