Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HelpCommand checks gets overwritten when set to bot.help_command #9827

Open
3 tasks done
InterStella0 opened this issue May 11, 2024 · 0 comments · May be fixed by #9843
Open
3 tasks done

HelpCommand checks gets overwritten when set to bot.help_command #9827

InterStella0 opened this issue May 11, 2024 · 0 comments · May be fixed by #9843
Labels
unconfirmed bug A bug report that needs triaging

Comments

@InterStella0
Copy link
Contributor

Summary

When you use HelpCommand.add_check, and set to bot.help_command, it overwritten

Reproduction Steps

  1. initialize the help command without checks kwarg
  2. use HelpCommand.add_check, i.e in init or outside
  3. 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

  • 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

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

@InterStella0 InterStella0 added the unconfirmed bug A bug report that needs triaging label May 11, 2024
@z03h z03h linked a pull request May 24, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug A bug report that needs triaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant