summary refs log tree commit diff
path: root/src/util/entities/Channel.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/entities/Channel.ts')
-rw-r--r--src/util/entities/Channel.ts24
1 files changed, 24 insertions, 0 deletions
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 {