From 3f5eb6a5954a91176d3e91c960cb8d82b3832540 Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Wed, 2 Jun 2021 15:52:53 +0200 Subject: [PATCH] Fix error message in help, fix help not working with mention prefix, fix error when pinning system messages (by adding an easter egg) --- cogs/help.py | 16 ++++++++++++++++ cogs/school.py | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cogs/help.py b/cogs/help.py index 7251b8e..c4b944b 100644 --- a/cogs/help.py +++ b/cogs/help.py @@ -22,6 +22,10 @@ class HelpCommand(commands.MinimalHelpCommand): if ctx.bot.locked: return + # If mention prefix was used, don't count it as a target + if ctx.message.content.startswith("<@"): + ctx.message.mentions = ctx.message.mentions[1:] + if len(ctx.message.mentions) > 5: return await ctx.send("Je kan Help maar naar maximaal 5 mensen doorsturen.") @@ -40,6 +44,10 @@ class HelpCommand(commands.MinimalHelpCommand): spl = command.split(" ") spl = spl[:len(spl) - len(self.ctx.message.mentions)] + # A person was mentioned without passing an argument + if not spl: + return await self.send_bot_help(self.get_bot_mapping()) + # Turn dic to lowercase to allow proper name searching all_commands = dict((k.lower(), v) for k, v in bot.all_commands.items()) @@ -115,6 +123,10 @@ class HelpCommand(commands.MinimalHelpCommand): embed.add_field(name=await self.get_command_signature(command), value=await self.add_aliases_formatting(sorted(command.aliases)) + helpDescription) for person in await self.get_destination(): + # Can't send to bots + if person.bot: + continue + await person.send(embed=embed) async def send_group_help(self, group): @@ -139,6 +151,10 @@ class HelpCommand(commands.MinimalHelpCommand): helpFile[self.get_name(subcommand).lower()], inline=False) for person in await self.get_destination(): + # Can't send to bots + if person.bot: + continue + await person.send(embed=embed) # Allow mentioning people to send it to them instead diff --git a/cogs/school.py b/cogs/school.py index eecfb36..89e68fe 100644 --- a/cogs/school.py +++ b/cogs/school.py @@ -96,8 +96,11 @@ class School(commands.Cog): if ctx.author.id in blacklist: return - await ctx.message.add_reaction("✅") + if message.is_system(): + return await ctx.send("Dus jij wil system messages pinnen?\nMag niet.") + await message.pin(reason="Didier Pin door {}".format(ctx.author.display_name)) + await ctx.message.add_reaction("✅") def setup(client):