feat: Added team leave
This commit is contained in:
@@ -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)
|
||||
|
@@ -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' })
|
||||
|
Reference in New Issue
Block a user