mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix: readd isThread type guard (#8019)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { ChannelType, Routes } = require('discord-api-types/v10');
|
||||
const Base = require('./Base');
|
||||
const { ThreadChannelTypes } = require('../util/Constants');
|
||||
let CategoryChannel;
|
||||
let DMChannel;
|
||||
let NewsChannel;
|
||||
@@ -109,6 +110,14 @@ class Channel extends Base {
|
||||
return this.client.channels.fetch(this.id, { force });
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this channel is a {@link ThreadChannel}.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isThread() {
|
||||
return ThreadChannelTypes.includes(this.type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this channel is {@link TextBasedChannels text-based}.
|
||||
* @returns {boolean}
|
||||
|
||||
1
packages/discord.js/typings/index.d.ts
vendored
1
packages/discord.js/typings/index.d.ts
vendored
@@ -750,6 +750,7 @@ export abstract class Channel extends Base {
|
||||
public get url(): string;
|
||||
public delete(): Promise<this>;
|
||||
public fetch(force?: boolean): Promise<this>;
|
||||
public isThread(): this is ThreadChannel;
|
||||
public isTextBased(): this is TextBasedChannel;
|
||||
public isDMBased(): this is PartialGroupDMChannel | DMChannel | PartialDMChannel;
|
||||
public isVoiceBased(): this is VoiceBasedChannel;
|
||||
|
||||
@@ -557,7 +557,7 @@ client.on('guildCreate', async g => {
|
||||
channel.send({ components: [row, row2] });
|
||||
}
|
||||
|
||||
if (channel.type === ChannelType.GuildPublicThread) {
|
||||
if (channel.isThread()) {
|
||||
const fetchedMember = await channel.members.fetch({ member: '12345678' });
|
||||
expectType<ThreadMember>(fetchedMember);
|
||||
const fetchedMemberCol = await channel.members.fetch(true);
|
||||
|
||||
Reference in New Issue
Block a user