Closed
Description
Summary
When trying to access the cog Attribute of a Slash Command, it always returns None.
Reproduction Steps
Create a Cog with a Slash Command and a Prefix (Normal) Command.
After adding them to the bot, check their cog attributes.
Minimal Reproducible Code
import discord
from discord.commands import slash_command
from discord.ext import commands
gids=[your_gids_here]
bot = commands.Bot()
class TestCog(commands.Cog):
def __init__(self, bot: discord.Bot) -> None:
self.bot = bot
@slash_command(guild_ids=gids)
async def other_command(self, ctx) -> None:
await ctx.respond("I should run!")
@commands.command(guild_ids=gids)
async def prefix_command(self, ctx) -> None:
await ctx.respond("I should run!")
bot.add_cog(TestCog(bot))
print(TestCog.other_command.cog)
print(TestCog.prefix_command.cog)
Expected Results
Both print statements return the Cog of the commands:
<__main__.TestCog object at 0x7f4ff2372c10>
<__main__.TestCog object at 0x7f4ff2372c10>
Actual Results
The Slash Command has its cog unset.
None
<__main__.TestCog object at 0x7f4ff2372c10>
Intents
Using default Intents
System Information
- Python v3.9.7-final
- py-cord v2.0.0-beta
- py-cord pkg_resources: v2.0.0b5
- aiohttp v3.7.4.post0
- system info:
Linux 4.18.0-358.el8.x86_64 #1 SMP Mon Jan 10 13:11:20 UTC 2022
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
Additional Context
Interestingly when getting the command via bot.get_command("other_command"), the cog attribute is set.