无法使用 pycord 发送临时 ("hidden") 消息



根据其他答案,下面的代码应该发送一个短暂的消息:
await ctx.send('Message Sent ✅', ephemeral=True)
但是当运行代码时,我得到这个错误:

Ignoring exception in command message:
Traceback (most recent call last):
File "/home/runner/bot/venv/lib/python3.8/site-packages/discord/commands/core.py", line 126, in wrapped
ret = await coro(arg)
File "/home/runner/bot/venv/lib/python3.8/site-packages/discord/commands/core.py", line 860, in _invoke
await self.callback(ctx, **kwargs)
File "main.py", line 39, in _slash
await ctx.send('Message Sent ✅', ephemeral=True)
TypeError: send() got an unexpected keyword argument 'ephemeral'  

这段代码似乎可以为其他人工作,所以我不确定我做错了什么。

Python版本:3.8
Pycord版本:Development(今早直接从dev分支安装)

Discord使用' response '来响应命令,'send'来发送消息到特定频道。只有响应是短暂的,所以你应该使用

await ctx.respond('Message Sent ✅', ephemeral=True)

需要理解的重要事情是,你需要一个交互来使消息短暂,因为没有交互,消息对谁来说是短暂的?这就是为什么它只适用于对交互的响应。

最新更新