mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
fix!: New folder structure and organize files
This commit is contained in:
1 parent
d92bd329dc
commit
39ff5ecb5d
83 files changed
+244
-246
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import config from 'config';
|
||||
import { EmbedBuilder, InteractionType } from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import { InteractionValidationError } from '../classes/interactions';
|
||||
import loggerModule from '../services/logger';
|
||||
import { EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||
import { ValidatorParams } from '../../types/utilTypes';
|
||||
import { useServerTranslator } from '../utils/localeUtil';
|
||||
import { formatSlashCommand } from '../utils/formattingUtils';
|
||||
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const systemOptions: SystemOptions = config.get('systemOptions');
|
||||
export const checkValidGuildId = async ({ interaction, executionId }: ValidatorParams) => {
|
||||
const logger: Logger = loggerModule.child({
|
||||
module: 'utilValidation',
|
||||
name: 'notValidGuildId',
|
||||
executionId: executionId,
|
||||
shardId: interaction.guild?.shardId,
|
||||
guildId: interaction.guild?.id
|
||||
});
|
||||
const translator = useServerTranslator(interaction);
|
||||
|
||||
const interactionIdentifier =
|
||||
interaction.type === InteractionType.ApplicationCommand ? interaction.commandName : interaction.customId;
|
||||
|
||||
if (interaction.guildId && !systemOptions.systemGuildIds.includes(interaction.guildId)) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
translator('validation.notValidGuildId', {
|
||||
icon: embedOptions.icons.warning,
|
||||
command: formatSlashCommand(interactionIdentifier, translator)
|
||||
})
|
||||
)
|
||||
.setColor(embedOptions.colors.warning)
|
||||
]
|
||||
});
|
||||
|
||||
logger.debug(
|
||||
`User tried to use command '${interactionIdentifier}' but system command cannot be executed in the specified guild.`
|
||||
);
|
||||
throw new InteractionValidationError('System command cannot be executed in the specified guild.');
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
Reference in new issue
Block a user