feat: Added team leave
All checks were successful
Build and Deploy / Deploy Web (push) Successful in 1m3s
Build and Deploy / Deploy Discord Bot (push) Successful in 43s

This commit is contained in:
2023-06-06 18:22:36 +02:00
parent 034e203c1e
commit f9c13e5ada
7 changed files with 64 additions and 17 deletions

View File

@@ -3,7 +3,7 @@ import { Schema, Types, model } from 'mongoose'
const userSchema = new Schema({
username: { type: String, required: false },
usernameType: { type: String, required: true, default: 'discord' },
teamId: { type: Types.ObjectId, ref: 'Team', required: false },
team: { type: Types.ObjectId, ref: 'Team', required: false },
discord: {
id: { type: String, required: true, unique: true },
username: { type: String, required: true }
@@ -31,9 +31,11 @@ const whitelistSchema = new Schema({
const teamSchema = new Schema({
name: { type: String, required: true, minLength: 3, maxLength: 16, unique: true, match: /^[a-zA-Z0-9]+$/ },
color: { type: String, required: true, match: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/ },
amount: { type: Number, required: true, default: 1 },
textChannelId: { type: String, required: false },
voiceChannelId: { type: String, required: false }
voiceChannelId: { type: String, required: false },
members: [
{ type: Types.ObjectId, ref: 'User' }
]
})
export const UserModel = model<IUser>('User', userSchema)

View File

@@ -33,7 +33,7 @@ export const getUser = async (userId: string, event: any) => {
}
try {
const user = await UserModel.findById(userId)
const user = await UserModel.findById(userId).populate('team')
if (!user) {
throw createError({ statusCode: 400, statusMessage: 'No user was found' })