Improved team system

This commit is contained in:
2023-05-11 19:46:18 +02:00
parent cde8e6c827
commit 51705f8651
22 changed files with 811 additions and 32 deletions

View File

@@ -1,3 +1,4 @@
import { ObjectId } from 'mongodb'
import jwt from 'jsonwebtoken'
const config = useRuntimeConfig()
@@ -48,3 +49,15 @@ export const getAuth = async (event) => {
})
}
}
export const applyUsername = async (user) => {
const teamsColl = db.collection('teams')
const team = await teamsColl.findOne({ _id: new ObjectId(user.team.id) })
const discordUsername = user.team ? user.username + ' [' + team.name + ']' : user.discord.username
await $fetch(config.discordHost + '/user/changenickname', {
method: 'POST',
body: { nickname: discordUsername, discordId: user.discord.id }
})
}