From 5b4efd13c9eced97f4160f9c4c19d1c843360943 Mon Sep 17 00:00:00 2001 From: DaStormer <40336269+DaStormer@users.noreply.github.com> Date: Thu, 5 Aug 2021 11:41:06 -0400 Subject: [PATCH] feat(Channel): add isVoice() (#6297) --- src/structures/Channel.js | 11 ++++++++++- typings/index.d.ts | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) 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; }