1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-23 02:42:28 +01:00

🐛 update user model on guild creation

This commit is contained in:
Flam3rboy 2021-02-17 19:00:46 +01:00
parent 0341fcf99c
commit 5e9dea0dd5
2 changed files with 8 additions and 2 deletions

View File

@ -35,7 +35,7 @@ export class DiscordServer extends Server {
await db.collection("messages").createIndex({ id: 1 }, { unique: true });
await db.collection("channels").createIndex({ id: 1 }, { unique: true });
await db.collection("guilds").createIndex({ id: 1 }, { unique: true });
await db.collection("members").createIndex({ id: 1 }, { unique: true });
await db.collection("members").createIndex({ id: 1, guild_id: 1 }, { unique: true });
await db.collection("roles").createIndex({ id: 1 }, { unique: true });
await db.collection("emojis").createIndex({ id: 1 }, { unique: true });
}

View File

@ -86,7 +86,7 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) =
max_presences: 250000,
max_video_channel_users: 25,
presence_count: 0,
member_count: 0,
member_count: 1, // TODO: if a addMemberToGuild() function will be used in the future, set this to 0 and automatically increment this number
mfa_level: 0,
preferred_locale: "en-US",
premium_subscription_count: 0,
@ -147,6 +147,12 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) =
},
}).save();
// TODO: I don't know why the bigint needs to be converted to a string in order to save the model.
// But the weird thing is, that it gets saved as a Long/bigint in the database
// @ts-ignore
user.guilds.push(guildID.toString());
await user.save();
// // TODO: emit Event
await emitEvent({
event: "GUILD_MEMBER_ADD",