【问题标题】:Discord.py Ban all discord bot commandDiscord.py 禁止所有不和谐的机器人命令
【发布时间】:2021-06-20 18:21:12
【问题描述】:

嗨,我正在尝试在 discord.py 中创建一个禁止所有成员的命令

@client.command()
async def massban(ctx):
    for user in ctx.guild.members:
        try:
            await user.ban()
        except:
            pass

此代码由于某种原因无法正常工作,谁能帮忙?

【问题讨论】:

  • 你有什么错误吗?

标签: discord.py


【解决方案1】:

您的机器人可能无权查看成员。确保机器人有这个:

intents = discord.intents
intents = discord.Intents.default()
intents.members = True
intents.dm_messages = True
intents.bans = True
client = discord.Client(intents=intents)

【讨论】:

  • 你需要先用discord.Intents声明intents变量。请在您的答案中包含这一点。
猜你喜欢
  • 2023-03-20
  • 1970-01-01
  • 2020-10-26
  • 2018-07-21
  • 2018-11-10
  • 1970-01-01
  • 2021-12-05
  • 2021-10-30
  • 2017-05-31
相关资源
最近更新 更多