From 96c55f6c6c5a0db3121a8f1880f92de27e390c50 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Tue, 10 Aug 2021 00:15:44 +0200 Subject: [PATCH] :bug: fix Member not deleted on guild delete --- src/routes/guilds/#guild_id/delete.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/routes/guilds/#guild_id/delete.ts b/src/routes/guilds/#guild_id/delete.ts index c363db25..6cca289e 100644 --- a/src/routes/guilds/#guild_id/delete.ts +++ b/src/routes/guilds/#guild_id/delete.ts @@ -4,6 +4,7 @@ import { GuildDeleteEvent, GuildModel, InviteModel, + MemberModel, MessageModel, RoleModel, UserModel @@ -30,13 +31,16 @@ router.post("/", async (req: Request, res: Response) => { guild_id: guild_id } as GuildDeleteEvent); - await GuildModel.deleteOne({ id: guild_id }).exec(); - await UserModel.updateMany({ guilds: guild_id }, { $pull: { guilds: guild_id } }).exec(); - await RoleModel.deleteMany({ guild_id }).exec(); - await ChannelModel.deleteMany({ guild_id }).exec(); - await EmojiModel.deleteMany({ guild_id }).exec(); - await InviteModel.deleteMany({ guild_id }).exec(); - await MessageModel.deleteMany({ guild_id }).exec(); + await Promise.all([ + GuildModel.deleteOne({ id: guild_id }).exec(), + UserModel.updateMany({ guilds: guild_id }, { $pull: { guilds: guild_id } }).exec(), + RoleModel.deleteMany({ guild_id }).exec(), + ChannelModel.deleteMany({ guild_id }).exec(), + EmojiModel.deleteMany({ guild_id }).exec(), + InviteModel.deleteMany({ guild_id }).exec(), + MessageModel.deleteMany({ guild_id }).exec(), + MemberModel.deleteMany({ guild_id }).exec() + ]); return res.sendStatus(204); });