Add global command channel rules and enhance command handling

- Introduced global command channel whitelist and blacklist in the GuildSettings model for improved command access control.
- Implemented command gate logic in the command routing to handle channel and role restrictions, providing user feedback for denied commands.
- Enhanced the CommandsManager component to support global rules and channel/role selection, improving the user interface for managing command permissions.
- Updated localization files to include new keys for global command rules and related messages, ensuring clarity in user interactions.
This commit is contained in:
TheOnlyMace
2026-07-22 20:26:40 +02:00
parent 0fb8195236
commit d31660f813
24 changed files with 963 additions and 185 deletions

View File

@@ -601,10 +601,10 @@ export type GuildBackupCreateDashboard = z.infer<typeof GuildBackupCreateDashboa
export const CommandOverrideDashboardSchema = z.object({
commandName: z.string().min(1).max(100),
enabled: z.boolean(),
allowedRoleIds: z.array(z.string()),
deniedRoleIds: z.array(z.string()),
allowedChannelIds: z.array(z.string()),
deniedChannelIds: z.array(z.string()),
allowedRoleIds: z.array(SnowflakeSchema),
deniedRoleIds: z.array(SnowflakeSchema),
allowedChannelIds: z.array(SnowflakeSchema),
deniedChannelIds: z.array(SnowflakeSchema),
cooldownSeconds: z.number().int().nonnegative().nullable()
});
export type CommandOverrideDashboard = z.infer<typeof CommandOverrideDashboardSchema>;
@@ -612,14 +612,42 @@ export type CommandOverrideDashboard = z.infer<typeof CommandOverrideDashboardSc
export const CommandOverrideDashboardUpsertSchema = z.object({
commandName: z.string().min(1).max(100),
enabled: z.boolean().default(true),
allowedRoleIds: z.array(z.string()).default([]),
deniedRoleIds: z.array(z.string()).default([]),
allowedChannelIds: z.array(z.string()).default([]),
deniedChannelIds: z.array(z.string()).default([]),
allowedRoleIds: z.array(SnowflakeSchema).default([]),
deniedRoleIds: z.array(SnowflakeSchema).default([]),
allowedChannelIds: z.array(SnowflakeSchema).default([]),
deniedChannelIds: z.array(SnowflakeSchema).default([]),
cooldownSeconds: z.number().int().nonnegative().nullable().optional()
});
export type CommandOverrideDashboardUpsert = z.infer<typeof CommandOverrideDashboardUpsertSchema>;
export const CommandGlobalRulesSchema = z.object({
allowedChannelIds: z.array(SnowflakeSchema),
deniedChannelIds: z.array(SnowflakeSchema)
});
export type CommandGlobalRules = z.infer<typeof CommandGlobalRulesSchema>;
export const CommandGlobalRulesPatchSchema = CommandGlobalRulesSchema.partial().refine(
(value) => Object.keys(value).length > 0,
{ message: 'At least one field is required' }
);
export type CommandGlobalRulesPatch = z.infer<typeof CommandGlobalRulesPatchSchema>;
export const DiscordChannelOptionSchema = z.object({
id: SnowflakeSchema,
name: z.string(),
type: z.number().int(),
parentId: SnowflakeSchema.nullable().optional()
});
export type DiscordChannelOption = z.infer<typeof DiscordChannelOptionSchema>;
export const DiscordRoleOptionSchema = z.object({
id: SnowflakeSchema,
name: z.string(),
color: z.number().int(),
position: z.number().int()
});
export type DiscordRoleOption = z.infer<typeof DiscordRoleOptionSchema>;
/**
* Known slash command names, aggregated from every module's
* `command-definitions.ts` (`SlashCommandBuilder#setName`). Used by the

View File

@@ -54,6 +54,10 @@ const de: Dictionary = {
'generic.error': 'Es ist ein Fehler aufgetreten.',
'generic.maintenance': 'Nexumi ist derzeit im Wartungsmodus. Bitte versuche es später erneut.',
'generic.unknownCommand': 'Unbekannter Befehl.',
'generic.commandDisabled': 'Dieser Befehl ist auf diesem Server deaktiviert.',
'generic.commandChannelBlocked': 'Dieser Befehl ist in diesem Kanal nicht erlaubt.',
'generic.commandRoleBlocked': 'Du darfst diesen Befehl mit deinen Rollen nicht nutzen.',
'generic.commandCooldown': 'Bitte warte noch {seconds} Sekunden, bevor du diesen Befehl erneut nutzt.',
'core.help.title': 'Nexumi Hilfe',
'core.help.subtitle': 'Commands nach Modul. Optional: `/help module:<name>`.',
'core.help.moduleLine': '**{module}**: {commands}',
@@ -587,6 +591,10 @@ const en: Dictionary = {
'generic.error': 'An error occurred.',
'generic.maintenance': 'Nexumi is currently in maintenance mode. Please try again later.',
'generic.unknownCommand': 'Unknown command.',
'generic.commandDisabled': 'This command is disabled on this server.',
'generic.commandChannelBlocked': 'This command is not allowed in this channel.',
'generic.commandRoleBlocked': 'You are not allowed to use this command with your roles.',
'generic.commandCooldown': 'Please wait {seconds} more seconds before using this command again.',
'core.help.title': 'Nexumi Help',
'core.help.subtitle': 'Commands by module. Optional: `/help module:<name>`.',
'core.help.moduleLine': '**{module}**: {commands}',