From ea18dea41167d5174da6ebeb813cc8fe8c14b268 Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Wed, 5 Jan 2022 19:36:47 +0100 Subject: [PATCH 1/2] Allow pins to use replies instead of arguments --- cogs/school.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cogs/school.py b/cogs/school.py index 4eefb70..cc6e43f 100644 --- a/cogs/school.py +++ b/cogs/school.py @@ -58,13 +58,27 @@ class School(commands.Cog): @commands.command(name="Pin", usage="[Message]") @help.Category(category=Category.Other) - async def pin(self, ctx, message: discord.Message): + async def pin(self, ctx, message: discord.Message = None): # In case people abuse, check if they're blacklisted blacklist = [] if ctx.author.id in blacklist: return + # Support replying to the message that should be pinned + if message is None: + reference = ctx.message.reference + + if reference is None: + return await ctx.reply("Controleer je argumenten.") + + # If the message is cached, avoid sending an API call + if not reference.cached_message: + # Message is always in the current channel because we came from a reply + message = await ctx.channel.fetch_message(reference.message_id) + else: + message = reference.cached_message + if message.is_system(): return await ctx.send("Dus jij wil system messages pinnen?\nMag niet.") From 16a4ba0e83e24121e72a79ac51f0e2dfd05149f9 Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Wed, 5 Jan 2022 19:37:59 +0100 Subject: [PATCH 2/2] Update help --- cogs/school.py | 2 +- files/help.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/school.py b/cogs/school.py index cc6e43f..520c87f 100644 --- a/cogs/school.py +++ b/cogs/school.py @@ -56,7 +56,7 @@ class School(commands.Cog): return await ctx.send(embed=s.create_schedule().to_embed()) - @commands.command(name="Pin", usage="[Message]") + @commands.command(name="Pin", usage="[Message]*") @help.Category(category=Category.Other) async def pin(self, ctx, message: discord.Message = None): # In case people abuse, check if they're blacklisted diff --git a/files/help.json b/files/help.json index 86cfdfe..545a3c4 100644 --- a/files/help.json +++ b/files/help.json @@ -75,7 +75,7 @@ "muttn": "Kiekt oeveel van ne muttn da [@Persoon] wel nie es aje eenen tagt, anders ist uzelf.", "neck": "<:WhatDidYou:744476950654877756><:DoTo:744476965951504414><:MyDrink:744476979939508275>", "nightly": "Daily is overrated.\nClaim jouw dagelijkse bonus Didier Dinks.", - "pin": "Pin [Message] zodat je geen admins hoeft te pingen. Misbruik kan je blacklisten.", + "pin": "Pin [Message] zodat je geen admins hoeft te pingen. Misbruik kan je blacklisten.\n\nJe kan ook replyen op de message die gepind moet worden in plaats van een argument op te geven.", "pjoke": "Didier vertelt een programming joke.", "poke": "Tik [Persoon].", "poke blacklist": "Indien je liever niet aan Poke wil deelnemen, kan je jezelf op deze manier blacklisten.\nIndien je jezelf wil ont-blacklisten stuur je een DM naar DJ STIJN (om misbruik tegen te gaan).",