Я создал класс MyBot следующим образом:
Код: Выделить всё
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 !")
Код: Выделить всё
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"))
Код: Выделить всё
discord.ext.commands.errors.CommandNotFound: Command "coucou" is not found
Он работает, если я не создаю класс и не помещаю весь код в один и тот же файл main. py, но я хочу использовать класс.
Подробнее здесь: https://stackoverflow.com/questions/792 ... -not-found