diff --git a/src/structures/Channel.js b/src/structures/Channel.js index 6c8e759c1b0c..cdae8152a586 100644 --- a/src/structures/Channel.js +++ b/src/structures/Channel.js @@ -1,7 +1,7 @@ 'use strict'; const Base = require('./Base'); -const { ChannelTypes } = require('../util/Constants'); +const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants'); const SnowflakeUtil = require('../util/SnowflakeUtil'); /** @@ -110,6 +110,14 @@ class Channel extends Base { return 'messages' in this; } + /** + * Indicates whether this channel is a thread channel. + * @returns {boolean} + */ + isThread() { + return ThreadChannelTypes.includes(this.type); + } + static create(client, data, guild) { const Structures = require('../util/Structures'); let channel; diff --git a/typings/index.d.ts b/typings/index.d.ts index 1d756d828f1f..43d12f69d8f4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -438,6 +438,7 @@ declare module 'discord.js' { public delete(reason?: string): Promise; public fetch(force?: boolean): Promise; public isText(): this is TextChannel | DMChannel | NewsChannel | ThreadChannel; + public isThread(): this is ThreadChannel; public toString(): string; }