简体   繁体   English

试图编写一个禁止所有用户的 python discord 机器人程序。 机器人只禁止没有角色的人?

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

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.该机器人有管理员,也有很高的角色,所以我不明白为什么它不会禁止有角色的人。

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.这似乎是一个简短的答案,但它就是它的全部。

There is a tag hierarchy so you might wanna move the bots tag to the top.有一个标签层次结构,因此您可能想将 bots 标签移到顶部。

标记在底部 顶部的标签

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM