discord.py
discord.py copied to clipboard
HelpCommand checks gets overwritten when set to bot.help_command
Summary
When you use HelpCommand.add_check, and set to bot.help_command, it overwritten
Reproduction Steps
- initialize the help command without
checkskwarg - use HelpCommand.add_check, i.e in init or outside
- assign to bot.help_command
Minimal Reproducible Code
help_command = commands.DefaultHelpCommand()
help_command.add_check(lambda ctx: False)
print(help_command._command_impl.checks) # [<function <lambda> at 0x000001E67FEE50D0>]
bot.help_command = help_command
print(help_command._command_impl.checks) # []
help_command.add_check(lambda ctx: False)
print(help_command._command_impl.checks) # [<function <lambda> at 0x000001E67FEE50D0>]
Expected Results
checks should be carried over after bot.help_command is set and not get overwritten.
Actual Results
checks are overwritten when setting to bot.help_command. This results in the checks not being applied when invoking the help command.
Intents
discord.Intents.all()
System Information
- Python v3.9.13-final
- discord.py v2.4.0-alpha
- discord.py metadata: v2.4.0a5025+g041abf8b
- aiohttp v3.9.5
- system info: Windows 10 10.0.22631
Checklist
- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.
Additional Context
checks do carried over if you set the checks kwarg on command_attrs.
help_command = commands.DefaultHelpCommand(command_attrs={'checks': [lambda ctx: False]})
help_command.add_check(lambda ctx: False)
bot.help_command = help_command
print(help_command._command_impl.checks) # [<function <lambda> at 0x0000027E06E35160>, <function <lambda> at 0x0000027E06F089D0>]
Happens since HelpCommand._add_to_bot only copies command_attrs but left out checks on the actual command impl here. Since command impl there gets overwritten, the checks disappear.
A simple fix would just be command.checks = self._command_impl.checks after this line but I don't like my approach