Discord.py
user banned by me, i want to see a list of banned user and id to remove the ban from user.
!banlist
- for made list of banned user name and id
In version 0.16.12 you can use client.get_bans(serverID)
which returns a list of User objects. You can then iterate through the list and get the id and name from each user. If you wanted to have the bot list the banned users' names and ids, you could do something like:
bannnedUsers = await client.get_bans(serverID)
for user in bannedUsers:
await client.send_message(channelID, user.name + ' ' + user.id)
In the rewrite branch it's a little more complicated. You would use guild.bans()
to get a list of tuples with each tuple containing a user object and a string with the reason for the ban. For the same result as before, you would do something like:
bans = await guild.bans()
for ban in bans:
await channel.send(ban[0].name + ' ' + ban[0].id)
It should be mentioned that the bot will need the ban_users permission to be able to access these coroutines.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments