有没有办法我可以禁止使用Discord.py Rewrite Bot

时间:2019-04-18 09:07:35

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

我如何在 Discord.py Rewrite 中发出取消禁止命令,我想清除我的问题,因为没有bot.unban命令(也许是)并且播放器不在列表中,所以我可以提及用户

编辑:

Traceback (most recent call last):
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 227, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\BKhushi\Desktop\gg\Discordgang.py", line 125, in on_command_error
    raise error
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 814, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 675, in invoke
    await self.prepare(ctx)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 640, in prepare
    await self._parse_arguments(ctx)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 561, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 427, in transform
    return await self.do_conversion(ctx, converter, argument, param)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 382, in do_conversion
    return await self._actual_conversion(ctx, converter, argument, param)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 328, in _actual_conversion
    ret = await instance.convert(ctx, argument)
  File "C:\Users\BKhushi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\converter.py", line 158, in convert
    raise BadArgument('User "{}" not found'.format(argument))
discord.ext.commands.errors.BadArgument: User "@<552510634303029298>" not found```

2 个答案:

答案 0 :(得分:2)

如果您有一个表示禁止的Member的{​​{1}}对象,则可以使用Member.unban。但是,在大多数情况下,您将不得不获取代表该用户的Member对象并使用Guild.unban

User

答案 1 :(得分:0)

我会考虑以下命令。我很抱歉在执行上述操作后没有发送消息,以获取有关如何在Discord.Py Rewrite中进行编写的更多信息,我建议您注意 here

  async def pardon(ctx, *, member):
      banned_users = await ctx.guild.bans()
      member_name, member_discriminator = member.split('#')

      for ban_entry in banned_users:
          user = ban_entry.banned_users

          if (user.name, user.discriminator) == (member_name, member_discriminator):
              await ctx.guild.unban(user)