Bejasc
Bejasc
Explore posts from servers
DIAdiscord.js - Imagine a boo! 👻
Created by Bejasc on 3/7/2024 in #djs-questions
member.setNickname or member.roles.add occasionally not working
Hi all, What reasons are there for a nickname potentially not being applied, or a role potentially not being applied? I have the following - which is fairly stock standard.
let aliveRole = RoleService.getRole(member.guild, "Alive");
if (!aliveRole) {
aliveRole = await RoleService.createRole(member.guild, { name: "Alive" });
}

await RoleService.addRole(member, aliveRole); // --> member.roles.add
const species = await SpeciesService.getSpecies(character.species);

const speciesRole = RoleService.getRole(member.guild, species.roleOptions.name);
await RoleService.addRole(member, speciesRole); // --> member.roles.add

if (member.user.id !== process.env.OWNER) {
//Only set nickname for non owner
await member.setNickname(character.name);
}
let aliveRole = RoleService.getRole(member.guild, "Alive");
if (!aliveRole) {
aliveRole = await RoleService.createRole(member.guild, { name: "Alive" });
}

await RoleService.addRole(member, aliveRole); // --> member.roles.add
const species = await SpeciesService.getSpecies(character.species);

const speciesRole = RoleService.getRole(member.guild, species.roleOptions.name);
await RoleService.addRole(member, speciesRole); // --> member.roles.add

if (member.user.id !== process.env.OWNER) {
//Only set nickname for non owner
await member.setNickname(character.name);
}
In some cases, the members nickname is not changed, or the alive role is not being added. (The species role seems to be correctly applied in every case). Usually, everything is applied correctly. I have not seen both the Alive role and the Nickname change not work. Most often - the nickname does not update.
I'm confused - because it seems sporadic. It's not a caching issue - the users display name is not changed on any client, even after refresh. To make things more confusing, the audit log appears to note the change - but the change does not appear to be applied. Am not getting and kind of error logs, the member object is defined (And other operations like those roles are working without issue)
8 replies