Skip to content

Commit

Permalink
Merge pull request #2 from hack-the-6ix/jeffrey-zang/assign-name-on-join
Browse files Browse the repository at this point in the history
Change user nickname on server join
  • Loading branch information
jeffrey-zang authored Jul 26, 2024
2 parents cdae175 + b8d463b commit 809a25d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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`);
}
})

client.login(process.env.DISCORD_BOT_TOKEN)

0 comments on commit 809a25d

Please sign in to comment.