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