npc203 / npc-cogs

My list of Cogs for Red-bot :p
MIT License
25 stars 25 forks source link

[CustomHelp] Ability to delete the command made by the user. #40

Closed AAA3A-AAA3A closed 3 years ago

AAA3A-AAA3A commented 3 years ago

Hello, Here is the code allowing the bot to delete the message that called the help menu. This feature is disabled by default and can be enabled by the bot owner with the command "[p]chelp settings deletemessage 1". Thanks in advance and have a nice day.

lgtm-com[bot] commented 3 years ago

This pull request introduces 1 alert when merging e5985ad8d442dd53b0ccfaa4f655767d00367132 into ba62ca36adc16e42eaf6bf7e3bc0f64242e704f8 - view on LGTM.com

new alerts:

npc203 commented 3 years ago

Just needs a small correction, an if condition to check if the bot has permissions to delete the user message.

npc203 commented 3 years ago
diff --git a/customhelp/core/base_help.py b/customhelp/core/base_help.py
--- customhelp/core/base_help.py
+++ customhelp/core/base_help.py
@@ -125,12 +125,10 @@
         """

         help_settings = await HelpSettings.from_context(ctx)

-        delete_message = await self.config.settings.deletemessage()
-        if delete_message:
-            if ctx.channel.permissions_for(ctx.me).manage_messages:
-                await ctx.message.delete()
+        if ctx.channel.permissions_for(ctx.me).manage_messages and await self.config.settings.deletemessage():
+            await ctx.message.delete()

         if help_for is None or isinstance(help_for, dpy_commands.bot.BotBase):
             await self.format_bot_help(ctx, help_settings=help_settings)
             return
lgtm-com[bot] commented 3 years ago

This pull request introduces 1 alert when merging 64ad4f360c7e2978d708ce4b388e837cc15abd74 into ba62ca36adc16e42eaf6bf7e3bc0f64242e704f8 - view on LGTM.com

new alerts:

npc203 commented 3 years ago

LGTM, thanks