mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
import config from 'config';
|
|
import { EmbedBuilder } from 'discord.js';
|
|
|
|
import loggerModule from '../../services/logger';
|
|
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
|
import { NotValidGuildIdParams } from '../../types/utilTypes';
|
|
|
|
const embedOptions: EmbedOptions = config.get('embedOptions');
|
|
const systemOptions: SystemOptions = config.get('systemOptions');
|
|
export const notValidGuildId = async ({ interaction, executionId }: NotValidGuildIdParams) => {
|
|
const logger = loggerModule.child({
|
|
source: 'systemCommandValidator.js',
|
|
module: 'utilValidation',
|
|
name: 'notValidGuildId',
|
|
executionId: executionId,
|
|
shardId: interaction.guild?.shardId,
|
|
guildId: interaction.guild?.id
|
|
});
|
|
|
|
if (interaction.guildId && !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)
|
|
]
|
|
});
|
|
|
|
logger.debug(
|
|
`User tried to use command '${interaction.commandName}' but system command cannot be executed in the specified guild.`
|
|
);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|