diff options
Diffstat (limited to 'src/util/entities/Channel.ts')
-rw-r--r-- | src/util/entities/Channel.ts | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index 2e5f030c..1f128713 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -35,7 +35,6 @@ import { Snowflake, trimSpecial, InvisibleCharacters, - ChannelTypes, } from "../util"; import { ChannelCreateEvent, ChannelRecipientRemoveEvent } from "../interfaces"; import { Recipient } from "./Recipient"; @@ -219,7 +218,7 @@ export class Channel extends BaseClass { !guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") && channel.name ) { - for (var character of InvisibleCharacters) + for (const character of InvisibleCharacters) if (channel.name.includes(character)) throw new HTTPError( "Channel name cannot include invalid characters", @@ -237,7 +236,7 @@ export class Channel extends BaseClass { 403, ); - if (channel.name.match(/\-\-+/g)) + if (channel.name.match(/--+/g)) throw new HTTPError( "Channel name cannot include multiple adjacent dashes.", 403, @@ -344,8 +343,9 @@ export class Channel extends BaseClass { relations: ["channel", "channel.recipients"], }); - for (let ur of userRecipients) { - let re = ur.channel.recipients!.map((r) => r.user_id); + for (const ur of userRecipients) { + if (!ur.channel.recipients) continue; + const re = ur.channel.recipients.map((r) => r.user_id); if (re.length === channelRecipients.length) { if (containsAll(re, channelRecipients)) { if (channel == null) { @@ -380,8 +380,8 @@ export class Channel extends BaseClass { const channel_dto = await DmChannelDTO.from(channel); - if (type === ChannelType.GROUP_DM) { - for (let recipient of channel.recipients!) { + if (type === ChannelType.GROUP_DM && channel.recipients) { + for (const recipient of channel.recipients) { await emitEvent({ event: "CHANNEL_CREATE", data: channel_dto.excludedRecipients([recipient.user_id]), |