【问题标题】:I want to make ban with role bot我想用角色机器人禁止
【发布时间】:2021-07-16 00:46:07
【问题描述】:

我想制作带角色的ban bot

但它引发了错误

这是我的代码:

@client.command()
async def roleban(ctx, role:discord.Role):
    for user in ctx.guild.members:
        if role in user:
            try:
                await user.ban()
            except:
                pass
        else:
            pass

和错误:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: argument of type 'Member' is not iterable

【问题讨论】:

标签: python-3.x discord.py


【解决方案1】:

但是,您可以使用 .roles 获取他们所有角色的列表。看看用户是否有给定的角色,我们可以使用user.roles

@client.command()
async def roleban(ctx, role:discord.Role):
    for user in ctx.guild.members:
        if role in user.roles:
            try:
                await user.ban()
            except:
                pass
        else:
            pass

欲了解更多信息,请访问this

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-24
    • 2023-03-15
    • 1970-01-01
    • 2019-03-28
    • 2021-04-02
    • 2018-06-26
    • 1970-01-01
    相关资源
    最近更新 更多