summary refs log tree commit diff
path: root/src/util/entities
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-27 03:49:04 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-27 03:50:33 +0200
commitec3f088c06029163f1489911dd6bb0a642353714 (patch)
tree6c802c4a8f06a048964a84f0b8aec620c769c079 /src/util/entities
parentMerge pull request #799 from MaddyUnderStars/feat/captchaVerify (diff)
parentMerge remote-tracking branch 'upstream/staging' into fix/categoryNames (diff)
downloadserver-ec3f088c06029163f1489911dd6bb0a642353714.tar.xz
Merge remote-tracking branch 'Maddy/fix/categoryNames' into staging
Diffstat (limited to '')
-rw-r--r--src/util/entities/Channel.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts

index 23fc6544..b17fdba0 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts
@@ -181,10 +181,16 @@ export class Channel extends BaseClass { for (let character of InvisibleCharacters) if (channel.name.includes(character)) throw new HTTPError("Channel name cannot include invalid characters", 403); - if (channel.name.match(/\-\-+/g)) throw new HTTPError("Channel name cannot include multiple adjacent dashes.", 403); + // Categories and voice skip these checks on discord.com + const skipChecksTypes = [ChannelType.GUILD_CATEGORY, ChannelType.GUILD_VOICE]; + if ((channel.type && !skipChecksTypes.includes(channel.type)) || guild.features.includes("IRC_LIKE_CHANNEL_NAMES")) { + if (channel.name.includes(" ")) throw new HTTPError("Channel name cannot include invalid characters", 403); - if (channel.name.charAt(0) === "-" || channel.name.charAt(channel.name.length - 1) === "-") - throw new HTTPError("Channel name cannot start/end with dash.", 403); + if (channel.name.match(/\-\-+/g)) throw new HTTPError("Channel name cannot include multiple adjacent dashes.", 403); + + if (channel.name.charAt(0) === "-" || channel.name.charAt(channel.name.length - 1) === "-") + throw new HTTPError("Channel name cannot start/end with dash.", 403); + } else channel.name = channel.name.trim(); //category names are trimmed client side on discord.com } if (!guild.features.includes("ALLOW_UNNAMED_CHANNELS")) {