【发布时间】:2020-02-12 18:43:18
【问题描述】:
我最近将我的机器人移动到了 cogs 中,但随之而来的是一些麻烦。我有一个命令,当您调用该命令时,它会让机器人重复一条消息。我希望机器人删除调用消息的命令,然后发送您键入的消息。我有这个(注意:当它不在齿轮中时它有效):
@commands.command()
async def say(self, ctx, *, arg=None):
if arg is None:
await ctx.send(f'{ctx.message.author.mention} Tell me what to say!')
if len(arg) > 50:
await ctx.send(f"{ctx.message.author.mention} That's too long!")
else:
await ctx.message.delete()
await ctx.send(f'''{arg}
- {ctx.message.author.mention}''')
代码运行并删除调用命令并发送消息的消息,但仍然抛出错误:
discord.errors.NotFound: 404 NOT FOUND (error code: 10008): Unknown Message
有什么办法可以解决这个问题吗?该命令再次起作用,但仍然抛出错误。
提前致谢。
编辑:经过一些测试,我想我已经找到了问题所在。我的代码的另一个问题是导致此问题,此代码本身不会导致错误。
如果其他人在迁移到 cog 时遇到类似问题,我的代码在 cog 中有一个 on_message 侦听器。我误加了await self.client.process_commands(message)
你不需要这个齿轮。
【问题讨论】:
标签: python discord.py