From c4c2cbf6d2490917f1ddc2632805c7410a00f23f Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 28 Mar 2021 18:51:58 -0400 Subject: [PATCH] [commands] Remove nullability from help command implementation Fixes #5154 --- discord/ext/commands/help.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/discord/ext/commands/help.py b/discord/ext/commands/help.py index 7791f75a1..a00b79f74 100644 --- a/discord/ext/commands/help.py +++ b/discord/ext/commands/help.py @@ -321,7 +321,7 @@ class HelpCommand: attrs.setdefault('name', 'help') attrs.setdefault('help', 'Shows this message') self.context = None - self._command_impl = None + self._command_impl = _HelpCommandImpl(self, **self.command_attrs) def copy(self): obj = self.__class__(*self.__original_args__, **self.__original_kwargs__) @@ -336,7 +336,6 @@ class HelpCommand: def _remove_from_bot(self, bot): bot.remove_command(self._command_impl.name) self._command_impl._eject_cog() - self._command_impl = None def add_check(self, func): """ @@ -350,13 +349,7 @@ class HelpCommand: The function that will be used as a check. """ - if self._command_impl is not None: - self._command_impl.add_check(func) - else: - try: - self.command_attrs["checks"].append(func) - except KeyError: - self.command_attrs["checks"] = [func] + self._command_impl.add_check(func) def remove_check(self, func): """ @@ -373,13 +366,7 @@ class HelpCommand: The function to remove from the checks. """ - if self._command_impl is not None: - self._command_impl.remove_check(func) - else: - try: - self.command_attrs["checks"].remove(func) - except (KeyError, ValueError): - pass + self._command_impl.remove_check(func) def get_bot_mapping(self): """Retrieves the bot mapping passed to :meth:`send_bot_help`."""