Answer the question
In order to leave comments, you need to log in
How to fix command not found error?
I’m sitting, cleaning up the chat, launching the bot and writing that the command was not found, although I even gave it a name.
Here is the code:
import discord # импортируем нужные библиотеки, и токен для бота.
from discord.ext import commands
from discord.ext.commands import Bot
from config import TOKEN
bot = Bot(command_prefix='!') # префикс бота перед командой
@bot.event
async def on_ready():
print(f'Logged on {bot.user}') # пишем что бот запустился
await bot.change_presence(status=discord.Status.do_not_disturb, activity=discord.Game("!help")) # статус бота, и игра в которую он играет
@bot.command()
async def hi(ctx):
await ctx.reply('Привет!') # первая команда, привет
@commands.command(name='clear')
async def clear(self, ctx, amount:int):
messages = await ctx.channel.purge(limit = amount + 1)
await ctx.send(f"{len(messages)} сообщений было очищено!")
bot.run(TOKEN)
Logged on Leqort#9720
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "clear" is not found
Answer the question
In order to leave comments, you need to log in
Didn't create a team.
Either you do it simply , or
, while registering it with
bot.add_command(test)
.
yes, but no registration
https://discordpy.readthedocs.io/en/stable/ext/com...
So the command is not created, or try:
@bot.command(name='clear')
async def _clear(self, ctx, amount:int):
messages = await ctx.channel.purge(limit = amount + 1)
await ctx.send(f"{len(messages)} сообщений было очищено!")
bot.add_command('clear')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question