python - 为什么我不断收到交互失败 (discord.py)
问题描述
我正在过渡到斜线命令,它们令人头疼。我已经在椅子上坐了一个多小时。这是测试斜杠命令。
@slash.slash(name="test",
description="This is just a test command, nothing more.")
async def _test(ctx):
await ctx.channel.send("Hello World!")
我做了这个测试斜线命令,看看它是否有效。长话短说,它没有。我的意思是,它出现了,但它实际上并没有做任何事情。它只是说“交互失败”。这不是唯一的问题,描述也不存在。它只是显示标题,老实说,我不想死去试图解决这个问题。这是我导入的内容:
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option
我想我应该提到我没有得到任何错误,这是一件坏事。任何帮助将不胜感激。
解决方案
当您响应消息时,您应该使用它ctx.send
来响应交互,而不是ctx.channel.send
向通道发送 POST 请求。如果您不响应交互,则会收到交互失败消息。
您也可以使用ctx.defer
回复,否则您最多可以有 15 分钟的时间回复您的互动。
推荐阅读
- node.js - 包中捆绑的本地依赖项在 npm install 上抛出错误
- javascript - 如何运行php函数onclick
- vue.js - 为什么刚刚触发子组件的挂载钩子时,我们可以获取父组件的整个 DOM?
- sudo - 在 `sudo` 中运行 ssh-keyscan 失败并显示 `Already running in a session`
- scala - 为什么表示 Tree 的泛型类型类具有 A 和 B 类型?
- python - Numpy获取二维数组中arange的索引
- python - 从模块导入类是否会在导入时执行整个模块?蟒蛇 3
- python - 如何用不同形状的数组替换数组
- c# - 隐藏文本框控件时流布局面板消失
- jenkins - 无法在 Jenkins 中配置系统电子邮件地址