From 53c69c4480f76cedd6cebea937d7298c5ceed595 Mon Sep 17 00:00:00 2001 From: H01001000 Date: Thu, 8 Dec 2022 22:32:55 +0800 Subject: [PATCH] type: close #2622 --- .../helpers/guilds/automod/editAutomodRule.ts | 3 +- packages/types/src/discord.ts | 40 +++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/packages/rest/src/helpers/guilds/automod/editAutomodRule.ts b/packages/rest/src/helpers/guilds/automod/editAutomodRule.ts index 3bc9588fd..af12a62b7 100644 --- a/packages/rest/src/helpers/guilds/automod/editAutomodRule.ts +++ b/packages/rest/src/helpers/guilds/automod/editAutomodRule.ts @@ -4,6 +4,7 @@ import type { BigString, DiscordAutoModerationRule, DiscordAutoModerationRuleTriggerMetadataPresets, + DiscordModifyAutomoderationRule, WithReason } from '@discordeno/types' import type { RestManager } from '../../../restManager.js' @@ -57,7 +58,7 @@ export async function editAutomodRule ( exempt_roles: options.exemptRoles?.map((id) => id.toString()), exempt_channels: options.exemptChannels?.map((id) => id.toString()), reason: options.reason - } + } as DiscordModifyAutomoderationRule ) return rest.transformers.automodRule(rest, result) diff --git a/packages/types/src/discord.ts b/packages/types/src/discord.ts index 99870284d..ffbcf9654 100644 --- a/packages/types/src/discord.ts +++ b/packages/types/src/discord.ts @@ -2553,28 +2553,26 @@ export interface DiscordCreateAutomoderationRule { /** The type of trigger to use for the rule. */ trigger_type: AutoModerationTriggerTypes /** The metadata to use for the trigger. */ - trigger_metadata: { - /** The keywords needed to match. Only present when TriggerType.Keyword */ - keyword_filter?: string[] - /** The pre-defined lists of words to match from. Only present when TriggerType.KeywordPreset */ - presets?: DiscordAutoModerationRuleTriggerMetadataPresets[] - /** The substrings which will exempt from triggering the preset trigger type. Only present when TriggerType.KeywordPreset */ - allow_list?: string[] - /** Total number of mentions (role & user) allowed per message (Maximum of 50). Only present when TriggerType.MentionSpam */ - mention_total_limit?: number - } + trigger_metadata: DiscordAutoModerationRuleTriggerMetadata /** The actions that will trigger for this rule */ - actions: Array<{ - /** The type of action to take when a rule is triggered */ - type: AutoModerationActionType - /** additional metadata needed during execution for this specific action type */ - metadata?: { - /** The id of channel to which user content should be logged. Only in SendAlertMessage */ - channel_id?: string - /** Timeout duration in seconds. Max is 2419200(4 weeks). Only supported for TriggerType.Keyword */ - duration_seconds?: number - } - }> + actions: DiscordAutoModerationAction[] + /** Whether the rule should be enabled, true by default. */ + enabled?: boolean + /** The role ids that should not be effected by the rule */ + exempt_roles?: string[] + /** The channel ids that should not be effected by the rule. */ + exempt_channels?: string[] +} + +export interface DiscordModifyAutomoderationRule { + /** The name of the rule. */ + name: string + /** The type of event to trigger the rule on. */ + event_type: AutoModerationEventTypes + /** The metadata to use for the trigger. */ + trigger_metadata: DiscordAutoModerationRuleTriggerMetadata + /** The actions that will trigger for this rule */ + actions: DiscordAutoModerationAction[] /** Whether the rule should be enabled, true by default. */ enabled?: boolean /** The role ids that should not be effected by the rule */