🐛 fix guild template create

This commit is contained in:
Flam3rboy 2021-09-25 04:20:11 +02:00
parent 7f0338aea0
commit 41f05a5abc

View File

@ -87,19 +87,21 @@ router.post("/", route({ body: "GuildCreateSchema" }), async (req: Request, res:
}); });
await Promise.all( await Promise.all(
body.channels?.map((x) => { body.channels
var id = ids.get(x.id) || Snowflake.generate(); ?.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) // TODO: should we abort if parent_id is a category? (to disallow sub category channels)
var parent_id = ids.get(x.parent_id); var parent_id = ids.get(x.parent_id);
return Channel.createChannel({ ...x, guild_id, id, parent_id }, req.user_id, { return Channel.createChannel({ ...x, guild_id, id, parent_id }, req.user_id, {
keepId: true, keepId: true,
skipExistsCheck: true, skipExistsCheck: true,
skipPermissionCheck: true, skipPermissionCheck: true,
skipEventEmit: true skipEventEmit: true
}); });
}) })
); );
await Member.addToGuild(req.user_id, guild_id); await Member.addToGuild(req.user_id, guild_id);