feat(ThreadMemberManager): allow individual members to be fetched (#6889)

Co-authored-by: ckohen <chaikohen@gmail.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
This commit is contained in:
Suneet Tipirneni
2021-10-29 08:57:53 -04:00
committed by GitHub
parent aa4d05504f
commit 14716df6b6
5 changed files with 49 additions and 10 deletions

2
typings/index.d.ts vendored
View File

@@ -2946,6 +2946,8 @@ export class ThreadMemberManager extends CachedManager<Snowflake, ThreadMember,
private constructor(thread: ThreadChannel, iterable?: Iterable<RawThreadMemberData>);
public thread: ThreadChannel;
public add(member: UserResolvable | '@me', reason?: string): Promise<Snowflake>;
public fetch(member?: UserResolvable, options?: BaseFetchOptions): Promise<ThreadMember>;
/** @deprecated Use `fetch(member, options)` instead. */
public fetch(cache?: boolean): Promise<Collection<Snowflake, ThreadMember>>;
public remove(id: Snowflake | '@me', reason?: string): Promise<Snowflake>;
}

View File

@@ -75,6 +75,7 @@ import {
TextBasedChannels,
TextChannel,
ThreadChannel,
ThreadMember,
Typing,
User,
VoiceChannel,
@@ -446,10 +447,17 @@ client.on('ready', async () => {
// This is to check that stuff is the right type
declare const assertIsPromiseMember: (m: Promise<GuildMember>) => void;
client.on('guildCreate', g => {
client.on('guildCreate', async g => {
const channel = g.channels.cache.random();
if (!channel) return;
if (channel.isThread()) {
const fetchedMember = await channel.members.fetch('12345678');
assertType<ThreadMember>(fetchedMember);
const fetchedMemberCol = await channel.members.fetch(true);
assertType<Collection<Snowflake, ThreadMember>>(fetchedMemberCol);
}
channel.setName('foo').then(updatedChannel => {
console.log(`New channel name: ${updatedChannel.name}`);
});