improved communication system

This commit is contained in:
2023-05-12 14:24:28 +02:00
parent d066915ec7
commit 0c7e6d8ee1
22 changed files with 139 additions and 12 deletions

View File

@@ -61,3 +61,13 @@ export const applyUsername = async (user) => {
body: { nickname: discordUsername, discordId: user.discord.id }
})
}
export const getUsernameWithTeam = async (user) => {
const teamsColl = db.collection('teams')
const team = user.team ? await teamsColl.findOne({ _id: new ObjectId(user.team.id) }): undefined;
const username = user.team ? user.username + ` [<color:${team.color}>${team.name}</color>]` : user.username;
const usernameWithoutStyle = user.team ? user.username + ` [${team.name}]` : user.username;
return { username: username, usernameWithoutStyle: usernameWithoutStyle, team: team }
}