У меня есть бот, две команды которого включают и отключают Cogs соответственно.
# main.py
...
async def load_ext(ctx, path: str):
bot.load_extension(path)
await ctx.reply(f"Loaded {path}")
async def unload_ext(ctx, path: str):
bot.unload_extension(path)
await ctx.reply(f"Unloaded {path}")
...
После того, как я "подключаю" и "отключаю" Cogs (в которых slash команды), они не работают. Хотя с обычными командами это работает.
# cog.py
import discord
from discord.ext import commands
class MyCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(cls=discord.SlashCommand, guild_ids=[<my guild id>])
async def some_cmd(self, ctx):
await ctx.send("Hello world")
def setup(bot):
bot.add_cog(MyCog(bot))
print("Loaded")
def teardown(bot):
bot.remove_cog("MyCog")
print("Unloaded")