diff --git a/src/structures/Channel.js b/src/structures/Channel.js index 37913046fd92..52867c645f05 100644 --- a/src/structures/Channel.js +++ b/src/structures/Channel.js @@ -97,6 +97,14 @@ class Channel extends Base { return this.client.channels.fetch(this.id, true, force); } + /** + * Indicates whether this channel is text-based. + * @returns {boolean} + */ + isText() { + return 'messages' in this; + } + 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 783238b18f9b..b0dddb5cdbb1 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -187,6 +187,7 @@ declare module 'discord.js' { public type: keyof typeof ChannelType; public delete(reason?: string): Promise; public fetch(force?: boolean): Promise; + public isText(): this is TextChannel | DMChannel | NewsChannel; public toString(): string; } @@ -826,6 +827,7 @@ declare module 'discord.js' { options: PermissionOverwriteOption, reason?: string, ): Promise; + public isText(): this is TextChannel | NewsChannel; } export class GuildEmoji extends BaseGuildEmoji {