From f1f6f8ad617749c9f5a180b80538cf305f6b45a0 Mon Sep 17 00:00:00 2001 From: jeffrey-zang Date: Thu, 25 Jul 2024 20:32:31 -0400 Subject: [PATCH 1/2] feat: assign name on join --- src/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index ea03091..140e8a3 100644 --- a/src/index.js +++ b/src/index.js @@ -6,9 +6,9 @@ const WOK = require('wokcommands'); const util = require('./util'); const WatchController = require('./controllers/WatchController'); +const UserController = require('./controllers/UserController'); const verificationQueueProcessor = require('./services/verificationQueueProcessor'); - const client = new Client({ intents: [ IntentsBitField.Flags.Guilds, @@ -67,4 +67,14 @@ client.on('messageCreate', (message) => { } }) +client.on('guildMemberAdd', async (member) => { + const userInfo = await UserController.getUserByDiscordID(member.id) + + if (userInfo) { + member.setNickname(userInfo.firstName + " " + userInfo.lastName); + } else { + console.log(`Discord user ${newMember.id} not linked, ignoring voice state change.`); + } +}) + client.login(process.env.DISCORD_BOT_TOKEN) \ No newline at end of file From b8d463bad34048b9bf926b436ba788c69c3338ae Mon Sep 17 00:00:00 2001 From: jeffrey-zang Date: Thu, 25 Jul 2024 21:15:03 -0400 Subject: [PATCH 2/2] fix console message --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 140e8a3..4ceefb6 100644 --- a/src/index.js +++ b/src/index.js @@ -73,7 +73,7 @@ client.on('guildMemberAdd', async (member) => { if (userInfo) { member.setNickname(userInfo.firstName + " " + userInfo.lastName); } else { - console.log(`Discord user ${newMember.id} not linked, ignoring voice state change.`); + console.log(`Discord user ${newMember.id} not linked`); } })