Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(AutoModerationActionExecution): add channel, user and member getters #9142

Merged
merged 6 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,33 @@ class AutoModerationActionExecution {
get autoModerationRule() {
return this.guild.autoModerationRules.cache.get(this.ruleId) ?? null;
}

/**
* The channel where this action was triggered from.
* @type {?TextBasedChannel}
* @readonly
*/
get channel() {
return this.guild.channels.cache.get(this.channelId) ?? null;
}

/**
* The user that triggered this action.
* @type {?User}
* @readonly
*/
get user() {
jaw0r3k marked this conversation as resolved.
Show resolved Hide resolved
return this.guild.client.users.cache.get(this.userId) ?? null;
}

/**
* The guild member that triggered this action.
* @type {?GuildMember}
* @readonly
*/
get member() {
return this.guild.members.cache.get(this.userId) ?? null;
}
}

module.exports = AutoModerationActionExecution;
3 changes: 3 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,11 @@ export class AutoModerationActionExecution {
public action: AutoModerationAction;
public ruleId: Snowflake;
public ruleTriggerType: AutoModerationRuleTriggerType;
public get user(): User | null;
public userId: Snowflake;
public get channel(): TextBasedChannel | null;
public channelId: Snowflake | null;
public get member(): GuildMember | null;
public messageId: Snowflake | null;
public alertSystemMessageId: Snowflake | null;
public content: string;
Expand Down