Pycord-Development / pycord

Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python
https://docs.pycord.dev
MIT License
2.74k stars 462 forks source link

discord.cog.Cog not loading correctly #1554

Closed Fallcrim closed 2 years ago

Fallcrim commented 2 years ago

Summary

One of my cogs is not correctly being registered

Reproduction Steps

It is a cog, with default implementation. Means a class with a few functions and a setup() function.

Minimal Reproducible Code

import ...
class Cog(discord.cog.Cog):
    def __init__(self, bot):
        self.bot = bot
    @discord.slash_command()
    async def command(self, ctx):
        ...

def setup(bot):
    bot.add_cog(Cog(bot))

Expected Results

The command should get loaded without any issue and be included in bot.extensions

Actual Results

The cog was loaded with raising an exception. After checking bot.extensions it wasn't there

Intents

discord.Intents.all()

System Information

Checklist

Additional Context

If you need any specific code please just tell me Otherwise kind regards :D

JustaSqu1d commented 2 years ago

Refer to #1528

Fallcrim commented 2 years ago

Thanks for the reference @JustaSqu1d. After adding the 'store' argument to the loading method, I got a traceback: TypeError: Command.__init__() missing 1 required positional argument: 'func'

Fallcrim commented 2 years ago

Actually I found out that the commands.Group causes the issue

Fallcrim commented 2 years ago

NOTE: Removed commands.Group and replaced it with discord.SlashCommandGroup. Now working