下一个命令中的斜杠命令



我正试图在我的机器人中制作斜杠命令。然而,当我运行机器人时,斜杠命令不会出现,我也尝试过重新激活机器人。这是我当前的代码

@client.slash_command(name="ping", description="Check bots ping!")
async def pingtest(interaction : Interaction):
await interaction.response.send_message(f"My ping is {round(client.latency * 1000)}ms")

是的,我确实有正确的导入,因为我知道斜杠命令需要特殊的导入,而且我有最新版本的nextcard。

这里可能有一些问题。

  1. 您尚未在邀请创建者中启用所有必要的权限。你需要启用机器人和应用程序要求

  2. 你还没等一个小时。Discord API要求所有斜杠命令在运行代码时需要大约一个小时才能更新。如果您现在只是为一台服务器进行测试或构建,则可以避免这种情况。方法如下。

serverID = serverIDYouAreTestingOnAsAnIntegerValue
@client.slash_command(name="ping", description="Check bots ping!", guild_ids=serverID)
async def pingtest(interaction : Interaction):
await interaction.response.send_message(f"My ping is {round(client.latency * 1000)}ms")
  1. 一个非常简单的错误,如果你在一个不是你的公会上测试,你可能没有斜杠命令权限

相关内容

最新更新