Skip to content

Commit

Permalink
fix(discord): Admin nickname change
Browse files Browse the repository at this point in the history
  • Loading branch information
daniluk4000 committed Apr 23, 2024
1 parent cfe32cd commit 4144593
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/server/plugins/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export default defineNitroPlugin(async (app) => {

if (user && existingUser.vatsim) {
await user.roles.add(discordRoleId);
await user.setNickname(`${ existingUser.vatsim.fullName } ${ existingUser.vatsim.id }`, 'Verification process');
if (!user.permissions.has(PermissionFlagsBits.Administrator)) {
await user.setNickname(`${ existingUser.vatsim.fullName } ${ existingUser.vatsim.id }`, 'Verification process');
}
}
}
else {
Expand Down
5 changes: 4 additions & 1 deletion src/server/routes/auth/vatsim/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createDBUser, getDBUserToken } from '~/utils/db/user';
import { vatsimAuthOrRefresh, vatsimGetUser } from '~/utils/backend/vatsim';
import { findUserByCookie } from '~/utils/backend/user';
import { discordClient, discordRoleId, discordServerId } from '~/server/plugins/discord';
import { PermissionFlagsBits } from 'discord.js';

export default defineEventHandler(async (event) => {
try {
Expand Down Expand Up @@ -57,7 +58,9 @@ export default defineEventHandler(async (event) => {
const user = await (await discordClient.guilds.fetch(discordServerId)).members.fetch(discordId);
if (user) {
await user.roles.add(discordRoleId);
await user.setNickname(`${ vatsimUser.personal.name_full } ${ vatsimUser.cid }`, 'Verification process');
if (!user.permissions.has(PermissionFlagsBits.Administrator)) {
await user.setNickname(`${ vatsimUser.personal.name_full } ${ vatsimUser.cid }`, 'Verification process');
}
}
}

Expand Down

0 comments on commit 4144593

Please sign in to comment.