我开始开发一个不和谐的机器人,但从一开始我就不太理解它。
当我在slash_command上输入!youtube时,我得到了这个结果,但我不知道我哪里出了问题。
GUILD_ID &为安全起见删除令牌
from nextcord import Interaction, SlashOption, ChannelType
from nextcord.abc import GuildChannel
from nextcord.ext import commands
import nextcord
GUILD_ID =
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
print("Ready")
@bot.slash_command(guild_ids=[GUILD_ID])
async def youtube(interaction : Interaction):
await interaction.response.send_message("hi")
bot.run('')结果忽略命令None中的异常:未找到nextcord.ext.commands.errors.CommandNotFound:命令"youtube“
发布于 2022-05-24 18:47:48
如果您键入/在您的消息字段在不和应该弹出一些东西,您可以选择机器人和命令。点击你的机器人图标,检查你的“youtube”命令是否在那里。如果是,只需单击它并按回车。此外,如果只使用Slash命令,则可以删除这一行:bot = commands.Bot(command_prefix='!'),因为它们不使用自定义命令前缀。
发布于 2022-11-09 14:09:20
您必须将名称包含在@client.slash_command()装饰器中。异步函数的名称并不重要。
你的代码,但有效:
from nextcord import Interaction, SlashOption, ChannelType
from nextcord.abc import GuildChannel
from nextcord.ext import commands
import nextcord
GUILD_ID =
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
print("Ready")
@bot.slash_command(name="youtube", description="whatever description you want(not required)",guild_ids=[GUILD_ID])
async def youtube(interaction : Interaction):
await interaction.response.send_message("hi")
bot.run('')‘斜杠命令的描述可以是您想要的任何东西。
https://stackoverflow.com/questions/71821662
复制相似问题