无法通过Pycord发送短暂的(“ hidden&quot”)消息

发布于 2025-02-04 19:28:48 字数 725 浏览 4 评论 0原文

根据其他答案,以下代码应发送短暂消息:
等待ctx.send('消息发送✅',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版本:开发(今天早上直接从开发分支机构安装)

According to other answers the following code should send an ephemeral message:
await ctx.send('Message Sent ✅', ephemeral=True)
But when running the code, I get this error:

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'  

This code seems to work for other people, so I'm not sure what I'm doing wrong.

Python Version: 3.8
Pycord Version: Development (installed directly from dev branch this morning)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吃→可爱长大的 2025-02-11 19:28:48

Discord使用“响应”来响应命令,然后“发送”将消息发送到特定的频道。只有响应才能是短暂的,因此您应该使用

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

重要的事情来理解,您需要进行互动来发出信息短暂的信息,因为没有一个人,该消息将是短暂的?这就是为什么它仅用于响应互动的原因。

Discord uses 'respond' to respond to commands and 'send' to send a message to a specific channel. Only responses can be ephemeral so you should use

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

The important thing to understand is that you need an interaction to make a message ephemeral because without one, who would the message be ephemeral to? That‘s why it only works for responses to interactions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文