簡體   English   中英

試圖編寫一個禁止所有用戶的 python discord 機器人程序。 機器人只禁止沒有角色的人?

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

代碼:

 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)

該機器人有管理員,也有很高的角色,所以我不明白為什么它不會禁止有角色的人。

您的機器人必須在您的服務器上具有最高角色才能禁止所有用戶。 這似乎是一個簡短的答案,但它就是它的全部。

有一個標簽層次結構,因此您可能想將 bots 標簽移到頂部。

標記在底部 頂部的標簽

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM