diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-25 04:20:11 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-25 04:20:11 +0200 |
commit | 6229398316b1cfbf110a501a67cbb537aa126549 (patch) | |
tree | 66a68229f504d98805a74194c76e9490564998fb /api | |
parent | :art: sort openapi tags by alphabet (diff) | |
download | server-6229398316b1cfbf110a501a67cbb537aa126549.tar.xz |
:bug: fix guild template create
Diffstat (limited to 'api')
-rw-r--r-- | api/src/routes/guilds/index.ts | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/api/src/routes/guilds/index.ts b/api/src/routes/guilds/index.ts index abde147d..6a325ae2 100644 --- a/api/src/routes/guilds/index.ts +++ b/api/src/routes/guilds/index.ts @@ -87,19 +87,21 @@ router.post("/", route({ body: "GuildCreateSchema" }), async (req: Request, res: }); await Promise.all( - body.channels?.map((x) => { - var id = ids.get(x.id) || Snowflake.generate(); - - // TODO: should we abort if parent_id is a category? (to disallow sub category channels) - var parent_id = ids.get(x.parent_id); - - return Channel.createChannel({ ...x, guild_id, id, parent_id }, req.user_id, { - keepId: true, - skipExistsCheck: true, - skipPermissionCheck: true, - skipEventEmit: true - }); - }) + body.channels + ?.sort((a, b) => (a.parent_id ? -1 : 1)) + .map((x) => { + var id = ids.get(x.id) || Snowflake.generate(); + + // TODO: should we abort if parent_id is a category? (to disallow sub category channels) + var parent_id = ids.get(x.parent_id); + + return Channel.createChannel({ ...x, guild_id, id, parent_id }, req.user_id, { + keepId: true, + skipExistsCheck: true, + skipPermissionCheck: true, + skipEventEmit: true + }); + }) ); await Member.addToGuild(req.user_id, guild_id); |