remove something specific from someones nickname

i want to make a bot where if someone has a nickname for example kermit - kelp it removes the - kelp and only keeps kermit, how do i do this? i tried before ( im an amateur; started like a 3 weeks ago) and i just kept getting errors
7 Replies
d.js toolkit
d.js toolkit2mo 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!
d.js docs
d.js docs2mo ago
:event: (event) Client#guildMemberUpdate @14.15.2 Emitted whenever a guild member changes - i.e. new role, removed role, nickname. :method: GuildMember#setNickname @14.15.2 Sets the nickname for this member.
// Set a nickname for a guild member
guildMember.setNickname('cool nickname', 'Needed a new nickname')
.then(member => console.log(`Set nickname of ${member.user.username}`))
.catch(console.error);
// Set a nickname for a guild member
guildMember.setNickname('cool nickname', 'Needed a new nickname')
.then(member => console.log(`Set nickname of ${member.user.username}`))
.catch(console.error);
Amgelo
Amgelo2mo ago
listen to that event, check its nickname and change if needed ^^
koutrou
koutrou2mo ago
the nickname is already there i just want it to go through the members of the discord, find the people with - kelp in their nickname and remove it is that possible?
d.js docs
d.js docs2mo ago
:property: Guild#members @14.15.2 A manager of the members belonging to this guild :method: GuildMemberManager#fetch @14.15.2 Fetches member(s) from a guild.
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
Amgelo
Amgelo2mo ago
just iterate there
koutrou
koutrou2mo ago
alright thanks