diff --git a/src/structures/Channel.js b/src/structures/Channel.js index d67b4f925745..6db653e96ff8 100644 --- a/src/structures/Channel.js +++ b/src/structures/Channel.js @@ -9,7 +9,7 @@ let StoreChannel; let TextChannel; let ThreadChannel; let VoiceChannel; -const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants'); +const { ChannelTypes, ThreadChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants'); const SnowflakeUtil = require('../util/SnowflakeUtil'); /** @@ -117,6 +117,15 @@ class Channel extends Base { return 'messages' in this; } + /** + * Indicates whether this channel is voice-based + * ({@link VoiceChannel} or {@link StageChannel}). + * @returns {boolean} + */ + isVoice() { + return VoiceBasedChannelTypes.includes(this.type); + } + /** * Indicates whether this channel is a {@link ThreadChannel}. * @returns {boolean} diff --git a/typings/index.d.ts b/typings/index.d.ts index de6e9de89a69..d99ccad2bc3c 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -354,6 +354,7 @@ export class Channel extends Base { public delete(): Promise; public fetch(force?: boolean): Promise; public isText(): this is TextBasedChannels; + public isVoice(): this is VoiceChannel | StageChannel; public isThread(): this is ThreadChannel; public toString(): ChannelMention; }