【发布时间】: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.
【问题讨论】: