types(Interaction): change inGuild return type (#6094)

This commit is contained in:
DTrombett
2021-07-14 17:14:20 +02:00
committed by GitHub
parent a9e7ebd94f
commit 60148c6a78
2 changed files with 6 additions and 1 deletions

2
typings/index.d.ts vendored
View File

@@ -831,7 +831,7 @@ export class Interaction extends Base {
public type: InteractionType;
public user: User;
public version: number;
public inGuild(): boolean;
public inGuild(): this is this & { guildId: Snowflake; member: GuildMember | APIInteractionGuildMember };
public isButton(): this is ButtonInteraction;
public isCommand(): this is CommandInteraction;
public isMessageComponent(): this is MessageComponentInteraction;

View File

@@ -15,6 +15,7 @@ import {
GuildMember,
GuildResolvable,
Intents,
Interaction,
Message,
MessageActionRow,
MessageAttachment,
@@ -604,3 +605,7 @@ client.on('messageReactionAdd', async reaction => {
if (reaction.message.partial) return assertType<string | null>(reaction.message.content);
assertType<string>(reaction.message.content);
});
// Test interactions
declare const interaction: Interaction;
if (interaction.inGuild()) assertType<Snowflake>(interaction.guildId);