如何修复帮会对象没有“帮会权限”属性的错误

2024-09-27 00:22:21 发布

您现在位置:Python中文网/ 问答频道 /正文

以下是给我带来问题的字符串:

@client.command(aliases=['unban'])
async def unban1(ctx, user: discord.User):
  guild = ctx.guild
  channel = ctx.message.channel
  embed4 = discord.Embed(
    title='Unbanning Member...',
    description= f"{user} has been unbanned.",
    colour=discord.Colour.teal() 
  )
  if ctx.author.guild.guild_permissions.ban_members:
    await channel.send (embed=embed4)
    await guild.unban(user=user)
    pass

我还没有准备好很多关于discord.py重写文档的内容,所以如果这是一个noob问题,请原谅,但是,请帮助!给出错误的问题在第10行


Tags: 字符串clientasyncdefchannelawaitcommandaliases
1条回答
网友
1楼 · 发布于 2024-09-27 00:22:21

删除.guild它的Member.guild_permissions而不是Member.guild.guild_permissions

@client.command(aliases=['unban'])
async def unban1(ctx, user: discord.User):
  guild = ctx.guild
  channel = ctx.message.channel
  embed4 = discord.Embed(
    title='Unbanning Member...',
    description= f"{user} has been unbanned.",
    colour=discord.Colour.teal() 
  )
  if ctx.author.guild_permissions.ban_members:
    await channel.send (embed=embed4)
    await guild.unban(user=user)
    pass

相关问题 更多 >

    热门问题