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 toolkit12mo 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
Dhymbot12mo 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 User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo ago
ok so
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo ago
also my english is not very good
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo ago
only i use english for programming oh, there is another variable? im changing the const rightnow
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo ago
then if (message.guild.getMember(targetMember.id).roles.has('ID_ROLE') === true) or idk
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo ago
i need to make another option in twice of user isn't it? now i see getUser -> getMember
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo ago
and addMemberOption
d.js docs
d.js docs12mo 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 User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo ago
xd
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo ago
then its easier
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo 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
Dhymbot12mo ago
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo 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 User12mo ago
Message Not Public
Sign In & Join Server To View
Dhymbot
Dhymbot12mo ago
ok
Dhymbot
Dhymbot12mo ago
it logs correctly when targetMember has or don't has the assigned role. Thnx @.gwapes , that's all
Dhymbot
Dhymbot12mo ago
im going to programme mod log msgs now, closing post