[Python] discord.ext.commands.errors.CommandNotFound: Command "coucou" is not found

Discussão em 'Python' iniciado por Stack, Novembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to create a bot Discord with Python. I created a class MyBot like this:

    import discord
    from discord.ext import commands

    intents = discord.Intents.all()
    intents.members = True

    class MyBot(commands.Bot):
    def __init__(self):
    super().__init__(command_prefix="!", intents=intents, description="My Bot !!")

    async def on_ready(self):
    print("My Bot is Online !")

    async def coucou(ctx):
    await ctx.send("You say coucou, i say coucou !")


    And in my main.py I have:

    import discord
    import os
    from discord.ext import commands
    from Classbot.class_bot import MyBot as MB

    from dotenv import load_dotenv
    load_dotenv(dotenv_path="config")

    bot = MB()
    bot.coucou()
    bot.run(os.getenv("mytoken"))


    The bot is online and I have the message "My Bot is Online !" but in Discord when I try: !coucou, I get this error:

    discord.ext.commands.errors.CommandNotFound: Command "coucou" is not found


    I don't succeed in calling the method coucou. It works if I don't create a class and put all the code in the same main.py page but I want to use a class.

    Continue reading...

Compartilhe esta Página