types(Partial): add partial reactions (#6066)

Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
DTrombett
2021-07-09 13:25:59 +02:00
committed by GitHub
parent 5b6be0cebc
commit d6c43a50bd
6 changed files with 65 additions and 98 deletions

View File

@@ -581,3 +581,25 @@ declare const guildEmojiManager: GuildEmojiManager;
assertType<Promise<Collection<Snowflake, GuildEmoji>>>(guildEmojiManager.fetch());
assertType<Promise<Collection<Snowflake, GuildEmoji>>>(guildEmojiManager.fetch(undefined, {}));
assertType<Promise<GuildEmoji | null>>(guildEmojiManager.fetch('0'));
// Test partials structures
client.on('typingStart', (channel, user) => {
if (channel.partial) assertType<undefined>(channel.lastMessageId);
if (user.partial) return assertType<null>(user.username);
assertType<string>(user.username);
});
client.on('guildMemberRemove', member => {
if (member.partial) return assertType<null>(member.joinedAt);
assertType<Date | null>(member.joinedAt);
});
client.on('messageReactionAdd', async reaction => {
if (reaction.partial) {
assertType<null>(reaction.count);
reaction = await reaction.fetch();
}
assertType<number>(reaction.count);
if (reaction.message.partial) return assertType<string | null>(reaction.message.content);
assertType<string>(reaction.message.content);
});