Fix error message in help, fix help not working with mention prefix, fix error when pinning system messages (by adding an easter egg)

pull/64/head
Stijn De Clercq 2021-06-02 15:52:53 +02:00
parent 10da82d211
commit 3f5eb6a595
2 changed files with 20 additions and 1 deletions

View File

@ -22,6 +22,10 @@ class HelpCommand(commands.MinimalHelpCommand):
if ctx.bot.locked: if ctx.bot.locked:
return 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: if len(ctx.message.mentions) > 5:
return await ctx.send("Je kan Help maar naar maximaal 5 mensen doorsturen.") 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 = command.split(" ")
spl = spl[:len(spl) - len(self.ctx.message.mentions)] 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 # Turn dic to lowercase to allow proper name searching
all_commands = dict((k.lower(), v) for k, v in bot.all_commands.items()) 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), embed.add_field(name=await self.get_command_signature(command),
value=await self.add_aliases_formatting(sorted(command.aliases)) + helpDescription) value=await self.add_aliases_formatting(sorted(command.aliases)) + helpDescription)
for person in await self.get_destination(): for person in await self.get_destination():
# Can't send to bots
if person.bot:
continue
await person.send(embed=embed) await person.send(embed=embed)
async def send_group_help(self, group): async def send_group_help(self, group):
@ -139,6 +151,10 @@ class HelpCommand(commands.MinimalHelpCommand):
helpFile[self.get_name(subcommand).lower()], inline=False) helpFile[self.get_name(subcommand).lower()], inline=False)
for person in await self.get_destination(): for person in await self.get_destination():
# Can't send to bots
if person.bot:
continue
await person.send(embed=embed) await person.send(embed=embed)
# Allow mentioning people to send it to them instead # Allow mentioning people to send it to them instead

View File

@ -96,8 +96,11 @@ class School(commands.Cog):
if ctx.author.id in blacklist: if ctx.author.id in blacklist:
return 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 message.pin(reason="Didier Pin door {}".format(ctx.author.display_name))
await ctx.message.add_reaction("")
def setup(client): def setup(client):