From b3657f2cc89bd67d1879f2a5f6589bb1cd11ff08 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 14 Jan 2023 13:25:16 +0100 Subject: Move isTextChannel to channel Signed-off-by: TheArcaneBrony --- src/util/entities/Channel.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/util/entities') diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index aaddc001..23f2ea55 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -450,6 +450,30 @@ export class Channel extends BaseClass { ]; return disallowedChannelTypes.indexOf(this.type) == -1; } + + isTextChannel(): boolean { + switch (this.type) { + case ChannelType.GUILD_STORE: + case ChannelType.GUILD_VOICE: + case ChannelType.GUILD_STAGE_VOICE: + case ChannelType.GUILD_CATEGORY: + case ChannelType.GUILD_FORUM: + case ChannelType.DIRECTORY: + throw new HTTPError("not a text channel", 400); + case ChannelType.DM: + case ChannelType.GROUP_DM: + case ChannelType.GUILD_NEWS: + case ChannelType.GUILD_NEWS_THREAD: + case ChannelType.GUILD_PUBLIC_THREAD: + case ChannelType.GUILD_PRIVATE_THREAD: + case ChannelType.GUILD_TEXT: + case ChannelType.ENCRYPTED: + case ChannelType.ENCRYPTED_THREAD: + return true; + default: + throw new HTTPError("unimplemented", 400); + } + } } export interface ChannelPermissionOverwrite { -- cgit 1.5.1