Closed M1N0RM1N3R closed 2 years ago
Does the workaround of using bot.create_group
not solve this issue?
Does the workaround of using
bot.create_group
not solve this issue?
Hmm, lemme try that...
Edit: Nada. IG to get it working rn I can just comment out @profile_cmd.command('create')
and replace it with @bot.slash_command('profile_create')
just to weather the storm till a fix can be found.
As a workaround, you can add my_command.cog = None
after the command creation like so:
g = bot.create_group("g")
@b.command()
async def foo(ctx):
ctx.respond("heya")
foo.cog = None
No idea if this has any side effects though.
EDIT: nevermind that breaks everything.
EDIT2: Here's the horrible, horrible workaround that seems to actually work. I'm pretty sure it will horribly break on updating anything and could have horrible side effects such as setting your computer on fire or posting your credit card data on linkedin. Please don't use it if you don't know what you're doing.
At the top of the file:
# OH THE HORRORS https://github.com/Pycord-Development/pycord/issues/1649
import discord.utils
discord.utils._MissingSentinel._get_overridden_method = lambda *args, **kwargs: None
discord.utils._MissingSentinel.cog_check = lambda *args, **kwargs: True
discord.utils._MissingSentinel.cog_before_invoke = lambda *args, **kwargs: None
discord.utils._MissingSentinel.cog_after_invoke = lambda *args, **kwargs: None
discord.utils._MissingSentinel.cog_command_error = lambda *args, **kwargs: None
When definint your command:
g = bot.create_group(g)
@g.command
async def cmd(_cog, ctx: ApplicationContext): ...
Note the added but unused _cog parameter.
This works because it makes _MissingSentinel
a kind of null object, which isn't the developers intention afaict.
The proper fix would maybe be to examine all places where cog is checked for is not None
and add or isinstance(the_thing.cog, _MissingSentinel)
but I don't really understand the code enough to gauge the impact.
Summary
SlashCommandGroups don't appear to be registering properly--when I start up my bot, the commands in SlashCommandGroups appear broken, whereas commands not in a group work fine.
Reproduction Steps
foo_cmd = discord.SlashCommandGroup('foo')
@foo_cmd.command()
bot.add_application_command(foo_cmd)
@bot.slash_command()
to compare and contrast for good measureMinimal Reproducible Code
Expected Results
Command shows correct args in Discord client, command runs as programmed
Actual Results
Commands created via
@bot.slash_command()
such as the /ping command in the MPC example function as expected. The commands in the SlashCommandGroup appear blank, with only the name. No arguments appear at all. When attempting to run one of the commands in the group, Discord shows a "The application did not respond" error and the terminal shows the following traceback. When I change the@profile_cmd.command()
to@bot.slash_command()
, the command works perfectly.Intents
None at the moment
System Information
Checklist
Additional Context
I believe this has worked properly in the past when I was running on Windows. It could just be me, but it suddenly stopped working after I switched over to Ubuntu 22.04 last weekend.