Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Channel): add isVoice() #6297

Merged
merged 1 commit into from Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/structures/Channel.js
Expand Up @@ -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');

/**
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions typings/index.d.ts
Expand Up @@ -354,6 +354,7 @@ export class Channel extends Base {
public delete(): Promise<Channel>;
public fetch(force?: boolean): Promise<Channel>;
public isText(): this is TextBasedChannels;
public isVoice(): this is VoiceChannel | StageChannel;
public isThread(): this is ThreadChannel;
public toString(): ChannelMention;
}
Expand Down