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
d.js toolkit
d.js toolkit4w ago
- 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!
Stiefanek Was Taken💅🏻
To get this I do this " const users = interaction.options.getUser('unholy'); const ID = users.id; const banUnholy = client.users.cache.get(ID) "
treble/luna
treble/luna4w ago
It indeed isnt a function
Stiefanek Was Taken💅🏻
Shouldn't a value be passed?
treble/luna
treble/luna4w ago
thats not valid js syntax
Stiefanek Was Taken💅🏻
of who to ban
treble/luna
treble/luna4w ago
Yes. But thats not valid syntax
d.js docs
d.js docs4w ago
:method: GuildBanManager#create() @14.16.3 Bans a user from the guild.
// Ban a user by id (or with a user/guild member object)
guild.bans.create('84484653687267328')
.then(banInfo => console.log(`Banned ${banInfo.user?.tag ?? banInfo.tag ?? banInfo}`))
.catch(console.error);
// Ban a user by id (or with a user/guild member object)
guild.bans.create('84484653687267328')
.then(banInfo => console.log(`Banned ${banInfo.user?.tag ?? banInfo.tag ?? banInfo}`))
.catch(console.error);
Stiefanek Was Taken💅🏻
The "84484653687267328" is the id. What would I put instead there? If you said banUnholy is not a valid syntax
treble/luna
treble/luna4w ago
The id. As a property I would recommend checking out #resources if you do not knownthe difference between a function and a property
Stiefanek Was Taken💅🏻
I know what the difference is but isn't this const banUnholy = client.users.cache.get(ID) a property?
treble/luna
treble/luna4w ago
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
Stiefanek Was Taken💅🏻
Whoops. I fixed it.
Stiefanek Was Taken💅🏻
Now I get this.
Code: await interaction.guild.bans.create(banUnholy.id, (reason)).catch(err => { return interaction.reply({ content: "Can't execute!", ephemeral: true}) })
No description
treble/luna
treble/luna4w ago
The second parameter is an object
That is not an object
d.js docs
d.js docs4w ago
:interface: BanOptions @14.16.3 Options used to ban a user from a guild.
Stiefanek Was Taken💅🏻
can you tell me what happened- when i press enter it shows the fields again
treble/luna
treble/luna4w ago
you didnt fill in a required option. As for why it displays like that, thats on discord's end
Stiefanek Was Taken💅🏻
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.
treble/luna
treble/luna4w ago
You're replying twice to the same interaction
Stiefanek Was Taken💅🏻
do you know how I would make it chat in a specific channel via the channel id?
treble/luna
treble/luna4w ago
get the channel from cache, like you did before, just now for channels, and call .send() on it
Stiefanek Was Taken💅🏻
TypeError: Cannot read properties of undefined (reading 'cache')
treble/luna
treble/luna3w ago
show your code
Stiefanek Was Taken💅🏻
Fixed. How would I get the displayname of the player in the specific server? And not on the whole discord
treble/luna
treble/luna3w ago
get the member object, which has a displayName
d.js docs
d.js docs3w ago
:method: GuildMemberManager#fetch() @14.16.3 Fetches member(s) from a guild.
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
Stiefanek Was Taken💅🏻
alright, one more thing, How do I figure out the userid of the person who ran the command?
Want results from more Discord servers?
Add your server