簡體   English   中英

“找不到命令” discord 機器人

[英]"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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM