Implement lockdown management in automod system
- Added functionality to activate and deactivate lockdowns via the automod worker, responding to specific job names. - Enhanced the anti-raid join handler to apply a verification role when lockdown is active and the anti-raid action is set to VERIFY. - Updated the automod configuration to ensure default rules are created if missing, improving the setup process for new guilds. - Introduced new API endpoints for managing cases and warnings, allowing for soft deletion and reason updates. - Enhanced the moderation dashboard to include warnings management, improving user experience in moderation tasks. - Updated localization files to reflect new features and improve user guidance in both English and German.
This commit is contained in:
@@ -140,12 +140,20 @@ export const commandLocales = {
|
||||
en: '0-21600'
|
||||
},
|
||||
'moderation.lock.description': {
|
||||
de: 'Aktuellen Textkanal sperren',
|
||||
en: 'Lock current text channel'
|
||||
de: 'Kanal oder gesamten Server sperren',
|
||||
en: 'Lock channel or entire server'
|
||||
},
|
||||
'moderation.lock.options.server': {
|
||||
de: 'Gesamten Server sperren (alle Textkanäle)',
|
||||
en: 'Lock the entire server (all text channels)'
|
||||
},
|
||||
'moderation.unlock.description': {
|
||||
de: 'Aktuellen Textkanal entsperren',
|
||||
en: 'Unlock current text channel'
|
||||
de: 'Kanal oder gesamten Server entsperren',
|
||||
en: 'Unlock channel or entire server'
|
||||
},
|
||||
'moderation.unlock.options.server': {
|
||||
de: 'Gesamten Server entsperren',
|
||||
en: 'Unlock the entire server'
|
||||
},
|
||||
'moderation.nick.description': {
|
||||
de: 'Nicknames verwalten',
|
||||
|
||||
@@ -6,7 +6,12 @@ import {
|
||||
import {
|
||||
embedHasContent,
|
||||
LeaveMessageTypeSchema,
|
||||
WelcomeEmbedSchema
|
||||
WelcomeEmbedSchema,
|
||||
AutoModRuleTypeSchema,
|
||||
AutoModActionSchema,
|
||||
AutoModExceptionsSchema,
|
||||
AutoModThresholdSchema,
|
||||
AutoModWordListSchema
|
||||
} from './phase2.js';
|
||||
import {
|
||||
SelfRoleBehaviorSchema,
|
||||
@@ -111,7 +116,18 @@ export type WarningListQuery = z.infer<typeof WarningListQuerySchema>;
|
||||
// AutoMod
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const AntiRaidActionSchema = z.enum(['LOCKDOWN']);
|
||||
export const AntiRaidActionSchema = z.enum(['LOCKDOWN', 'VERIFY']);
|
||||
|
||||
export const AutomodRuleDashboardSchema = z.object({
|
||||
ruleType: AutoModRuleTypeSchema,
|
||||
enabled: z.boolean(),
|
||||
action: AutoModActionSchema,
|
||||
durationMs: z.number().int().positive().nullable().optional(),
|
||||
threshold: AutoModThresholdSchema.default({}),
|
||||
exceptions: AutoModExceptionsSchema.default({ roleIds: [], channelIds: [] }),
|
||||
wordList: AutoModWordListSchema.default({ words: [], regexPatterns: [] })
|
||||
});
|
||||
export type AutomodRuleDashboard = z.infer<typeof AutomodRuleDashboardSchema>;
|
||||
|
||||
export const AutomodConfigDashboardSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
@@ -123,13 +139,30 @@ export const AutomodConfigDashboardSchema = z.object({
|
||||
antiNukeBanThreshold: z.number().int().positive(),
|
||||
antiNukeChannelThreshold: z.number().int().positive(),
|
||||
antiNukeWindowSeconds: z.number().int().positive(),
|
||||
lockdownActive: z.boolean()
|
||||
lockdownActive: z.boolean(),
|
||||
rules: z.array(AutomodRuleDashboardSchema)
|
||||
});
|
||||
export type AutomodConfigDashboard = z.infer<typeof AutomodConfigDashboardSchema>;
|
||||
|
||||
export const AutomodConfigDashboardPatchSchema = nonEmptyPatch(AutomodConfigDashboardSchema);
|
||||
export type AutomodConfigDashboardPatch = z.infer<typeof AutomodConfigDashboardPatchSchema>;
|
||||
|
||||
export const CaseUpdateDashboardSchema = z.object({
|
||||
reason: z.string().trim().min(1).max(1000)
|
||||
});
|
||||
export type CaseUpdateDashboard = z.infer<typeof CaseUpdateDashboardSchema>;
|
||||
|
||||
/** Returns true when every regex pattern compiles. */
|
||||
export function validateAutomodRegexPatterns(patterns: string[]): string | null {
|
||||
for (const pattern of patterns) {
|
||||
try {
|
||||
RegExp(pattern, 'iu');
|
||||
} catch {
|
||||
return pattern;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Logging
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user