首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nextcord错误,nextcord.ext.commands.errors.CommandNotFound

nextcord错误,nextcord.ext.commands.errors.CommandNotFound
EN

Stack Overflow用户
提问于 2022-04-11 00:46:14
回答 2查看 530关注 0票数 0

我开始开发一个不和谐的机器人,但从一开始我就不太理解它。

当我在slash_command上输入!youtube时,我得到了这个结果,但我不知道我哪里出了问题。

GUILD_ID &为安全起见删除令牌

代码语言:javascript
复制
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“

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-05-24 18:47:48

如果您键入/在您的消息字段在不和应该弹出一些东西,您可以选择机器人和命令。点击你的机器人图标,检查你的“youtube”命令是否在那里。如果是,只需单击它并按回车。此外,如果只使用Slash命令,则可以删除这一行:bot = commands.Bot(command_prefix='!'),因为它们不使用自定义命令前缀。

票数 0
EN

Stack Overflow用户

发布于 2022-11-09 14:09:20

您必须将名称包含在@client.slash_command()装饰器中。异步函数的名称并不重要。

你的代码,但有效:

代码语言:javascript
复制
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('')

‘斜杠命令的描述可以是您想要的任何东西。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71821662

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档