TransWikia.com

Trying to program a python discord bot that bans all users. The bot only bans people without a role?

Stack Overflow Asked by Minewell 15 on November 4, 2021

Code:

 import discord

TOKEN = "{Removed for safety}"      # Put your Bot token here
SKIP_BOTS = False
fetch_offline_members = True

client = discord.Client()

@client.event
async def on_ready():
    print('Logged in!')
    for member in client.get_all_members():
        if member.bot and SKIP_BOTS:
            continue
        try:
            await member.ban(reason="Banned by BanBot", delete_message_days=7)
            print(f"Banned {member.display_name}!")
        except:
            print(f"Could not ban {member.display_name}")
    print("Banning is complete!")


client.run(TOKEN)

The bot has admin, and a high role too, so I don’t understand why it won’t ban people with a role.

2 Answers

There is a tag hierarchy so you might wanna move the bots tag to the top.

Tag at the bottom Tag at the top

Answered by Redfer on November 4, 2021

Your bot must have the highest role possible on your server in order to ban all users. This seems like a short answer but it is all there is to it.

Answered by skyrimking 409 on November 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP