Couldn't resolve the user id to unban
I made a ban and unban commands for my bot. Even though my ban command works without any problems, I am having problems with my unban command. Even if the person is banned, when I use /unban, it says "This user is not banned" and it does not unban the person. Also, an error message appears on the console.
Note: My bot has BanMembers and Administrator perm
14 Replies
- 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!
- ✅
Marked as resolved by OPbefore addressing the actual error, is there a reason you're not using a user option?
the person is not on the server, so we cannot find that person on userOption. Am I wrong?
it won't have them in the autocomplete, but it can still accept a user that's not in the server
which is to say, discord will still validate the id for you
lemme try
If I get an error again i will write back
There isn't any error
that error message discord is giving seems to indicate
id
is an integer option
please ensure that you've deployed commands since changing themi already deployed commands
since changing the option to a user option?
Oh wait
I was able to write the ID but the application did not respond
no error message
I wrote the command again and now it says "the user is not banned" and it did not unban
no error msg again
then to address that, that'd be because
<CommandInteractionOptionResolver>.getUser()
returns a User
object, and <User>.id
is a string
a string will never be equal to an entire User
object
you can entirely skip fetching bans and finding an existing ban since attempting to unban them is already an api call that will tell you whether they're banned (by rejecting if they're not banned)honestly it wouldn't be a lie if i said i was confused. can you show me what i need to change?
you can entirely skip fetching bans and finding an existing bantechnically you don't need to change the name of the variable
userId
, but it is a misleading namethanks for help i fixed
have a great day