diff --git a/src/structures/Interaction.js b/src/structures/Interaction.js index 189b3de03ec3..ee7140fb527a 100644 --- a/src/structures/Interaction.js +++ b/src/structures/Interaction.js @@ -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} diff --git a/typings/index.d.ts b/typings/index.d.ts index fdabb0426d7f..a854a68adde7 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -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;