summary refs log tree commit diff
path: root/api/src/util/Channel.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-24 16:35:04 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-24 16:35:04 +0200
commitef4d4a318176c3e572adc17427a8b8c728a618ab (patch)
treed95fedbf18b7b7438613b08b72eb30fa5fca8921 /api/src/util/Channel.ts
parent:sparkles: typeorm entities (diff)
downloadserver-ef4d4a318176c3e572adc17427a8b8c728a618ab.tar.xz
:construction: api
Diffstat (limited to 'api/src/util/Channel.ts')
-rw-r--r--api/src/util/Channel.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/api/src/util/Channel.ts b/api/src/util/Channel.ts

index fb6f9c8c..a618d2df 100644 --- a/api/src/util/Channel.ts +++ b/api/src/util/Channel.ts
@@ -1,10 +1,10 @@ import { ChannelCreateEvent, - ChannelModel, + Channel, ChannelType, emitEvent, getPermission, - GuildModel, + Guild, Snowflake, TextChannel, toObject, @@ -29,7 +29,7 @@ export async function createChannel( case ChannelType.GUILD_TEXT: case ChannelType.GUILD_VOICE: if (channel.parent_id && !opts?.skipExistsCheck) { - const exists = await ChannelModel.findOne({ id: channel.parent_id }, { guild_id: true }).exec(); + const exists = await Channel.findOneOrFail({ id: channel.parent_id }, { guild_id: true }); if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400); if (exists.guild_id !== channel.guild_id) throw new HTTPError("The category channel needs to be in the guild"); } @@ -49,7 +49,7 @@ export async function createChannel( if (!channel.permission_overwrites) channel.permission_overwrites = []; // TODO: auto generate position - channel = await new ChannelModel({ + channel = await new Channel({ ...channel, ...(!opts?.keepId && { id: Snowflake.generate() }), created_at: new Date(), @@ -57,7 +57,7 @@ export async function createChannel( recipient_ids: null }).save(); - await emitEvent({ event: "CHANNEL_CREATE", data: toObject(channel), guild_id: channel.guild_id } as ChannelCreateEvent); + await emitEvent({ event: "CHANNEL_CREATE", data: channel), guild_id: channel.guild_id } as ChannelCreateEvent; return channel; }