Skip to content

Commit

Permalink
feat(AutoModerationActionExecution): add channel, user and `membe…
Browse files Browse the repository at this point in the history
…r` getters (#9142)

* feat(AutoModerationActionExecution): add channel prop

* feat(AutoModerationActionExecution): add user prop

* fix: sintax

* feat: add guildmember getter

* Apply suggestions from code review

Co-authored-by: Almeida <[email protected]>

---------

Co-authored-by: Almeida <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 25, 2023
1 parent e78b8ad commit 095bd77
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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() {
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

2 comments on commit 095bd77

@vercel
Copy link

@vercel vercel bot commented on 095bd77 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 095bd77 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.