Skip to content

Commit

Permalink
feat(AutoModeration): Support custom_message (#9171)
Browse files Browse the repository at this point in the history
* feat: initial commit

* docs: fix type

* docs: this is probably a better explanation

* docs: optional

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
Jiralite and kodiakhq[bot] committed Feb 25, 2023
1 parent a9495bd commit c1000b8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/discord.js/src/managers/AutoModerationRuleManager.js
Expand Up @@ -75,6 +75,7 @@ class AutoModerationRuleManager extends CachedManager {
* @typedef {Object} AutoModerationActionMetadataOptions
* @property {GuildTextChannelResolvable|ThreadChannel} [channel] The channel to which content will be logged
* @property {number} [durationSeconds] The timeout duration in seconds
* @property {string} [customMessage] The custom message that is shown whenever a message is blocked
*/

/**
Expand Down Expand Up @@ -130,6 +131,7 @@ class AutoModerationRuleManager extends CachedManager {
metadata: {
duration_seconds: action.metadata?.durationSeconds,
channel_id: action.metadata?.channel && this.guild.channels.resolveId(action.metadata.channel),
custom_message: action.metadata?.customMessage,
},
})),
enabled,
Expand Down Expand Up @@ -186,6 +188,7 @@ class AutoModerationRuleManager extends CachedManager {
metadata: {
duration_seconds: action.metadata?.durationSeconds,
channel_id: action.metadata?.channel && this.guild.channels.resolveId(action.metadata.channel),
custom_message: action.metadata?.customMessage,
},
})),
enabled,
Expand Down
1 change: 1 addition & 0 deletions packages/discord.js/src/structures/AutoModerationRule.js
Expand Up @@ -96,6 +96,7 @@ class AutoModerationRule extends Base {
* @typedef {Object} AutoModerationActionMetadata
* @property {?Snowflake} channelId The id of the channel to which content will be logged
* @property {?number} durationSeconds The timeout duration in seconds
* @property {?string} customMessage The custom message that is shown whenever a message is blocked
*/

/**
Expand Down
1 change: 1 addition & 0 deletions packages/discord.js/src/util/Transformers.js
Expand Up @@ -28,6 +28,7 @@ function _transformAPIAutoModerationAction(autoModerationAction) {
metadata: {
durationSeconds: autoModerationAction.metadata.duration_seconds ?? null,
channelId: autoModerationAction.metadata.channel_id ?? null,
customMessage: autoModerationAction.metadata.custom_message ?? null,
},
};
}
Expand Down
1 change: 1 addition & 0 deletions packages/discord.js/typings/index.d.ts
Expand Up @@ -4543,6 +4543,7 @@ export interface AutoModerationAction {
export interface AutoModerationActionMetadata {
channelId: Snowflake | null;
durationSeconds: number | null;
customMessage: string | null;
}

export interface AutoModerationTriggerMetadata {
Expand Down

2 comments on commit c1000b8

@vercel
Copy link

@vercel vercel bot commented on c1000b8 Feb 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on c1000b8 Feb 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.