Ban does not work?
When I try to do this:
""
await interaction.guild.bans.create(banUnholy.id (reason)).catch(err => {
return interaction.reply({ content: "Can't execute!", ephemeral: true})
})
""
Then it says "banUnholy.id" is not a function!
29 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!To get this I do this
"
const users = interaction.options.getUser('unholy');
const ID = users.id;
const banUnholy = client.users.cache.get(ID)
"
It indeed isnt a function
Shouldn't a value be passed?
thats not valid js syntax
of who to ban
Yes. But thats not valid syntax
The "84484653687267328" is the id. What would I put instead there?
If you said banUnholy is not a valid syntax
The id. As a property
I would recommend checking out #resources if you do not knownthe difference between a function and a property
I know what the difference is
but isn't this
const banUnholy = client.users.cache.get(ID)
a property?
Then you would know how to solve this issue
yes
banunholy.id(reason) is a function
The create call takes 2 params
The second is an object with a reason key
Whoops.
I fixed it.
Now I get this.
Code: await interaction.guild.bans.create(banUnholy.id, (reason)).catch(err => { return interaction.reply({ content: "Can't execute!", ephemeral: true}) })
Code: await interaction.guild.bans.create(banUnholy.id, (reason)).catch(err => { return interaction.reply({ content: "Can't execute!", ephemeral: true}) })
The second parameter is an objectThat is not an object
can you tell me what happened-
when i press enter it shows the fields again
you didnt fill in a required option. As for why it displays like that, thats on discord's end
Alright, ban works.
I tried to do unban like this. And it didnt work and errored like this:
Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
Because of this:
await interaction.guild.bans.remove(unbanholy.id).catch(err => {
return interaction.reply({ content: "Can't execute!", ephemeral: true})
})
Do you know why?
I am pretty sure I did everything right this time.
You're replying twice to the same interaction
do you know how I would make it chat in a specific channel
via the channel id?
get the channel from cache, like you did before, just now for channels, and call .send() on it
TypeError: Cannot read properties of undefined (reading 'cache')
show your code
Fixed. How would I get the displayname of the player in the specific server?
And not on the whole discord
get the member object, which has a displayName
alright, one more thing, How do I figure out the userid of the person who ran the command?