我是 python 3.10 discord.py 编码器,当我尝试运行代码时,它给出了代码下方提到的错误

问题描述 投票:0回答:0

这是我的python bot unban命令代码

@Sapphire.command() @commands.has_permissions(ban_members=True) async def unban(ctx, *, member): """从服务器中解禁一个成员。""" banned_users = await ctx.guild.bans() member_name,member_discriminator = member.split("#")

for ban_entry in banned_users:
    user = ban_entry.user
    if (user.name, user.discriminator) == (member_name, member_discriminator):
        await ctx.guild.unban(user)
        await ctx.send(embed=discord.Embed(description=f"Unbanned {user.mention}", color=0xc700ff))
        unban_embed = discord.Embed(description=f"{user} has been unbanned from this server. | Unbanned by {ctx.author.name}", color=0xc700ff)
        await ctx.send(embed=unban_embed)
        try:
            await user.send(embed=discord.Embed(description=f"You have been unbanned from **{ctx.guild.name}** by **{ctx.author.name}**.", color=0xc700ff))
        except discord.Forbidden:
            pass
        break
else:
    await ctx.send(f"Could not find a banned user with the name {member}.")

当我尝试运行命令 unban 它给了我这个错误: 发生错误:命令引发异常:TypeError:对象 async_generator 不能用于 'await' 表达式

我预计代码应该在 python 3.10 中工作,但它没有

python asynchronous discord.py
© www.soinside.com 2019 - 2024. All rights reserved.