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
commita567551c8a6b03a956d21354a5504b9f9e1f40b1 (patch)
tree4f8242ecfa92c8a58e040a8dc705daafb2e68d6c /api/src/util/Channel.ts
parent:sparkles: typeorm entities (diff)
downloadserver-a567551c8a6b03a956d21354a5504b9f9e1f40b1.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; }