Подключил коги к дискорд боту, но вылезает ошибка, менял скрипт несколько раз, ничего не работает, вылезает ошибка:
Traceback (most recent call last):
File "C:\Users\user\Desktop\mybot\bot\bot.py", line 59, in <module>
bot.load_extension(f"plugins.{filename[:-3]}")
File "D:\Python\Lib\site-packages\disnake\ext\commands\common_bot_base.py", line 523, in load_extension
self._load_from_module_spec(spec, name)
File "D:\Python\Lib\site-packages\disnake\ext\commands\common_bot_base.py", line 469, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
disnake.ext.commands.errors.ExtensionFailed: Extension 'plugins.help' raised an error: NameError: name 'Help' is not defined
[Finished in 1.1s]
Что я сделал не так?
bot.py
import disnake
import os
from disnake.ext import commands
from disnake.utils import get
BOT_TOKEN =
intents=disnake.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents)
bot.remove_command('help')
@bot.event
async def on_ready():
print("- BOT -")
print()
print(f"Bot name: {bot.user.name}")
print()
print(f"Bot id: {bot.user.id}")
print()
activity = disnake.Game(name="!help", type=3)
await bot.change_presence(status=disnake.Status.online, activity=activity)
@bot.command()
async def ping(ctx):
await ctx.send("Pong!")
for filename in os.listdir("./plugins"):
if filename.endswith(".py"):
bot.load_extension(f"plugins.{filename[:-3]}")
bot.run(BOT_TOKEN)
help.py
import disnake
from disnake.ext import commands
class Help(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def test(self, ctx):
await ctx.send("test")
def setup(bot):
bot.add_cog(Help(bot))