在 Discord.py 重写中使用 commands.Greedy 时出错
Error using commands.Greedy in Discord.py Rewrite
每当我尝试使用 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.py,原来我有一个没有 this
的旧版本
每当我尝试使用 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.py,原来我有一个没有 this
的旧版本