mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(Interaction): add guild guard (#5955)
* feat(Interaction): add guild guard * fix: remove possibly uncached getters & duplicate method * fix: boolean ensuring Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com> Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
706c6eae60
commit
87e8cdd3eb
@@ -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}
|
||||
|
||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -1212,6 +1212,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;
|
||||
|
||||
Reference in New Issue
Block a user