[英]"Command not found" discord bot
所以我正在制作一个带有多个命令的 discord 机器人,但似乎只有最上面的那个可以工作。
import discord
import os
import time
import discord.ext
from discord.utils import get
from discord.ext import commands, tasks
from discord.ext.commands import has_permissions, CheckFailure, check
client = discord.Client()
client = commands.Bot(command_prefix = '$')
count = 0
@client.event
async def on_ready():
print("Ready")
@client.command()
async def clear(ctx, amount=100):
await ctx.channel.purge(limit=amount)
return
async def hello(ctx):
await ctx.send("Hi")
async def help(ctx):
await ctx.send("Hi")
client.run(("token"))
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "hello" is not found
如果您能告诉我出了什么问题,我将不胜感激。
如果没有装饰器,function 没有注册为命令,因此无法执行,每次都要放
@client.command()
async def clear(ctx, amount=100):
await ctx.channel.purge(limit=amount)
return
@client.command() # The decorator must be put here
async def hello(ctx):
await ctx.send("Hi")
@client.command() # ... and here too, everytime a function is a command
async def help(ctx):
await ctx.send("Hi")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.