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(Interaction): add guild guard #5955

Merged
merged 3 commits into from Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions src/structures/Interaction.js
Expand Up @@ -105,6 +105,14 @@ class Interaction extends Base {
return this.client.guilds.cache.get(this.guildID) ?? null;
}

/**
* Indicates whether this interaction is received from a guild.
* @returns {boolean}
*/
inGuild() {
return Boolean(this.guildID && this.member);
}

/**
* Indicates whether this interaction is a command interaction.
* @returns {boolean}
Expand Down
1 change: 1 addition & 0 deletions typings/index.d.ts
Expand Up @@ -1191,6 +1191,7 @@ declare module 'discord.js' {
public type: InteractionType;
public user: User;
public version: number;
public inGuild(): boolean;
public isButton(): this is ButtonInteraction;
public isCommand(): this is CommandInteraction;
public isMessageComponent(): this is MessageComponentInteraction;
Expand Down