首页 > 解决方案 > 我可以撤销 on_command discord.py 中的命令吗?

问题描述

我有功能

async def dedupetwo(self, message):

我正在检查命令是否不是垃圾邮件,所以我通过调用获取消息历史记录是通道

async for m in message.channel.history(limit=2, before=message.message):
                lastmsg = m

然后检查命令是否与该频道中的最后一条消息相同

if lastmsg.clean_content == ctx.message.clean_content:

我正试图在这个阶段撤销该命令的调用,但我找不到任何能够做到这一点的调用。是否有任何功能可以满足这一点,或者我应该如何做到这一点?

标签: python-3.xdiscord.py

解决方案


如果语句满足,您可以使用return来结束函数/命令if

if lastmsg.clean_content == ctx.message.clean_content:
    return

推荐阅读