【问题标题】:Discord.py Bot messaging channel issueDiscord.py Bot 消息传递通道问题
【发布时间】:2020-10-26 15:06:32
【问题描述】:

我开始使用 discord.py 在 discord 上制作机器人,但我遇到了一个无法解决的问题。目标是制作一个命令,使机器人消息成为带有特定消息的特定频道。这是代码

@commands.has_any_role("Phantom","XX")
async def msg(ctx,*, Msg = None):
   await ctx.send(f"Please give the channel ID. You can do this by saying ``.ID (IDhere)``")
   @client.command()
   async def ID(ctx,*, ID = 0):
       message = Msg
       channel = client.get_channel(ID)
       await channel.send(message)
       await ctx.send(f":white_check_mark: Message sent")

我第一次运行整个命令时,它按预期工作,第二次我说 .msg 命令时,我得到这个错误:

  File "C:\Users\Jack\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: Command ID is already registered.

【问题讨论】:

    标签: python variables


    【解决方案1】:

    您必须在使用之前注册命令,因此解决方案是在程序顶部定义命令,以便在启动时只需加载您要使用的所有命令。

    这是您要查找的内容:How to fix "discord.errors.ClientException: Command kick is already registered." error?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-04
      • 2020-09-11
      • 1970-01-01
      • 2021-08-11
      • 2021-08-23
      • 2021-10-04
      相关资源
      最近更新 更多