【问题标题】:Error using commands.Greedy in Discord.py RewriteDiscord.py Rewrite 中使用 commands.Greedy 时出错
【发布时间】:2018-10-04 22:39:10
【问题描述】:

每当我尝试使用commands.Greedy 时,我都会得到AttributeError: module 'discord.ext.commands' has no attribute 'Greedy'。这是我的代码:

@client.command(description="Kicks user", usage="[@user(s)]", brief="Kicks user")
@commands.has_role(settings.admin_role_name)
async def kick(self, ctx, targets: commands.Greedy[discord.Member], *reason: str):
    for target in targets:
        await target.kick(reason="{} ({}) used .kick command with the reason {}".format(ctx.message.author.name, ctx.message.author.id, reason))
        await ctx.send("<@{}> kicked <@{}>\n**Reason:** {}".format(ctx.message.author.id, target.id, reason))

@client.command(description="Bans user", usage="[@user]", brief="Bans user")
@commands.has_role(settings.admin_role_name)
async def ban(self, ctx, targets: commands.Greedy[discord.Member], *reason: str):
    for target in targets:
        await target.ban(reason="{} ({}) used .kick command with the reason {}".format(ctx.message.author.name, ctx.message.author.id, reason))
        await ctx.message.channel.send("{} banned <@{}>\n**Reason:** {}".format(ctx.message.author.id, target.id, reason))

我的discord版本是discord.py 1.0.0a1561+g53433bc

【问题讨论】:

    标签: discord discord.py discord.py-rewrite


    【解决方案1】:

    我重新安装了discord.py,原来我有一个没有this的旧版本

    【讨论】:

      猜你喜欢
      • 2020-11-27
      • 2020-02-23
      • 1970-01-01
      • 1970-01-01
      • 2019-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多