GuildMember.setNickname weird issue

Im using a modal for my discords verify system, where they input text and that text then becomes their nickname. 90% of the time it works but then sometimes it doesn't set their nickname? There is no error and it runs the code afterwards still which gives them a role, I created logs for it and it logs the correct nickname it was meant to set it to as well. My Intents
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
partials: [
Partials.Message, Partials.Channel, Partials.GuildMember, Partials.User
]
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
partials: [
Partials.Message, Partials.Channel, Partials.GuildMember, Partials.User
]
My code
const channel = interaction.guild.channels.cache.get('1133327003337097256')
channel.send({ content: `${interaction.member}: ${nickname}`}) // Nickname logs
try {
const guildMember = await interaction.guild.members.fetch(interaction.member.id)
guildMember.setNickname(nickname);
guildMember.roles.add("1129006050641707058");
} catch (error) {
console.log(error)
}


await interaction.reply({
content: "You have been verified!",
ephemeral: true,
});
const channel = interaction.guild.channels.cache.get('1133327003337097256')
channel.send({ content: `${interaction.member}: ${nickname}`}) // Nickname logs
try {
const guildMember = await interaction.guild.members.fetch(interaction.member.id)
guildMember.setNickname(nickname);
guildMember.roles.add("1129006050641707058");
} catch (error) {
console.log(error)
}


await interaction.reply({
content: "You have been verified!",
ephemeral: true,
});
Please ping me if you can help cause I may not see it otherwise :) Thanks
11 Replies
d.js toolkit
d.js toolkit17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
peachy
peachyOP17mo ago
[email protected] Node: v18.16.1
chewie
chewie17mo ago
Is the bot trying to set thr nickname on the owner of the server? If yes thats not possible
peachy
peachyOP17mo ago
No, just new server members.
peachy
peachyOP17mo ago
Take this for example, it set the nickname of the 1st person in the image but not the second person. The weird part is, it says in the audit logs that it changed their name but it actually didn't.
chewie
chewie17mo ago
Sounds like a cache issue with your discord then Does it show the nickname when you restart discord
peachy
peachyOP17mo ago
Negative, should I try fetching the member with force: true or maybe cache: false?
chewie
chewie17mo ago
Nah
peachy
peachyOP17mo ago
Okay, could It be an issue of the user not being cached yet? Like most people do it as soon as they join the discord.
chewie
chewie17mo ago
If the audit log says the nickname was changed, then there isnt really anything you can do
peachy
peachyOP17mo ago
Hmm thats odd then, I guess Ill just have to keep manually changing the nicknames of those that don't work. Or do a dodgy work around and save the name to a database and when they send a message without their nickname set it sets it again.
Want results from more Discord servers?
Add your server