I don't know how to make a conditional "if" in setTimeout() (related to roles)

Hi!!! So, i was trying to make a mute command, and the good thing is i was able to creating it. However, i use the function setTimeout() to create a cooldown when the role "MUTEADO" (muted) deletes automatically at a specific time. The problem is that if i make a conditional, checking if user has "MUTEADO" role, always says something is not a function, or similar. Ive tried so many things, so tell me any ideas to make the conditional on line 50 work fine. Thank you!
28 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Dhymbot
DhymbotOP2y ago
discordjs v14.11.0 node -v version 18.12.0 The error is literally the following image (at the following code that don't works, even i've tried so many ways)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
ok so
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
also my english is not very good
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
only i use english for programming oh, there is another variable? im changing the const rightnow
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
then if (message.guild.getMember(targetMember.id).roles.has('ID_ROLE') === true) or idk
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
i need to make another option in twice of user isn't it? now i see getUser -> getMember
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
and addMemberOption
d.js docs
d.js docs2y ago
Despite sounding similar there is a distinct difference between users and members in Discord: - User: global Discord user data (global avatar, username, tag, id) - GuildMember: user data associated to a guild (guild, nickname, roles, voice, guild avatar, etc.) - Conversion: User ➞ GuildMember | GuildMember ➞ User * Note: Events received in cached guilds will often have both the member and user available, eg. interaction.user and interaction.member
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
xd
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
then its easier
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
im making the changes Ok, now that error is solved. i have an issue but it was my fault and i can solve it
Dhymbot
DhymbotOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
no need for the === true bc if its nil just don't do anything right? the problem was that role wasn't specified outside from the conditional"if (interaction.member.roles.cache.some(role => rolesPermitidos.includes(role.id)))" if the server wants to restart i check the problem
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Dhymbot
DhymbotOP2y ago
ok
Dhymbot
DhymbotOP2y ago
it logs correctly when targetMember has or don't has the assigned role. Thnx @.gwapes , that's all
Dhymbot
DhymbotOP2y ago
im going to programme mod log msgs now, closing post
Want results from more Discord servers?
Add your server