-
-
Couldn't load subscription status.
- Fork 482
Description
Summary
Autocomplete methods are not executed for slash commands that are under a SlashCommandGroup.
Reproduction Steps
I created a slash command group, and added commands with autocomplete to the group. The commands would be registered successfully, but autocomplete would not work.
Minimal Reproducible Code
import discord
import environment
bot = discord.Bot()
class CustomCog(discord.Cog):
group = discord.SlashCommandGroup(name="test")
async def autocomplete(ctx):
return ["hello world"]
@group.command()
async def random_subcommand(self, ctx, random: discord.Option(str, name="random", autocomplete=autocomplete)):
await ctx.respond(random)
bot.add_cog(CustomCog(bot))
bot.run(environment.DISCORD_TOKEN)Expected Results
When running the bot and typing the /test random_subcommand command, the text hello world should be suggested.
Actual Results
The autocomplete method in my code did not run, and no results were suggested. Discord showed an error after a couple of seconds: "Loading options failed".
Intents
Intents.default()
System Information
- Python v3.9.6-final
- py-cord v2.1.3-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19044
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
Using a debugger I narrowed it down to this line, where the command variable is a SlashCommandGroup, not a SlashCommand. I would have submitted a PR but I saw that line was introduced in 2.1.2 (e321fa3) and assume that simply removing it (which does fix the issue) will undo whatever fixes were made with that change.
Temporary Fix
My bots weren't experiencing any of the bugs that were fixed in v2.1.2+, so reverting to v2.1.1 works as a temporary fix for me. But your mileage may vary.