Unbanning all members
Hello, i want my bot to unban all banned people from the server, how can i do it?
23 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I have this code atm:
but i get this error:
TypeError: interaction.guild.fetchBans is not a function
What version?
This is for v14:
https://discord.js.org/#/docs/discord.js/main/class/GuildBanManager?scrollTo=fetch
Discord.js
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Okay my code is this now:
But i get
DiscordAPIError: Cannot send an empty message
You may hit a rate limit so just be careful when doing so!
But i do have people banned.
Ye ik
Okie dokie, just to be on the safe side!
I have 3 people banned so should be fine atm.
But for some reason it doesn't get the list of abnned people
Which DJS version are you using?
13.9
Bans has a cache
Just gonna say that lol
try
interaction.guild.bans.cache
The promise returns a collection of guildBans
Not users directly
Discord.js
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
I should do .....cache.fetch().then......... right?
You still can
like this.
bannedMembers is a Collection of GuildBans
So you have to map the guild bans to user tags
You’re veryyy close
And now i gotta make a foreach thing that unbans them?
That should be it
Just make sure to include a wait function of whatever you seen fit.
this works as well, more simple xd
user.user.id 🤢
I would rename user to guildBan
But up to you
👍🏻