1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-06 10:52:31 +01:00

Apply suggestions from code review

Co-authored-by: Erkin Alp Güney <erkinalp9035@gmail.com>
This commit is contained in:
Madeline 2022-01-15 18:00:54 +11:00 committed by Erkin Alp Güney
parent 10e617e4ab
commit b08bb30075

View File

@ -161,7 +161,8 @@ export class Channel extends BaseClass {
if (!opts?.skipNameChecks) { if (!opts?.skipNameChecks) {
const guild = await Guild.findOneOrFail({ id: channel.guild_id }); const guild = await Guild.findOneOrFail({ id: channel.guild_id });
if (!guild.features.includes("ILLEGAL_CHANNEL_NAMES") && channel.name) { if (!guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") && channel.name) {
for (var character of InvisibleCharacters) for (var character of InvisibleCharacters)
channel.name = channel.name.split(character).join("-"); channel.name = channel.name.split(character).join("-");
@ -169,7 +170,8 @@ export class Channel extends BaseClass {
channel.name = channel.name.split("-").filter(Boolean).join("-"); //trim '-' character channel.name = channel.name.split("-").filter(Boolean).join("-"); //trim '-' character
} }
if (!guild.features.includes("NULL_CHANNEL_NAMES")) { if (!guild.features.includes("ALLOW_UNNAMED_CHANNELS")) {
if (channel.name) channel.name = channel.name.trim(); if (channel.name) channel.name = channel.name.trim();
if (!channel.name) throw new HTTPError("Channel name cannot be empty."); if (!channel.name) throw new HTTPError("Channel name cannot be empty.");