diff --git a/cogs/context_menus/school_cm.py b/cogs/context_menus/school_cm.py new file mode 100644 index 0000000..f65e609 --- /dev/null +++ b/cogs/context_menus/school_cm.py @@ -0,0 +1,32 @@ +import discord +from discord import ApplicationContext +from discord.ext import commands +from discord.commands import message_command + +from startup.didier import Didier + + +class SchoolCM(commands.Cog): + def __init__(self, client: Didier): + self.client: Didier = client + + @message_command(name="Pin") + async def _pin_cm(self, ctx: ApplicationContext, message: discord.Message): + # In case people abuse, check if they're blacklisted + blacklist = [] + + if ctx.user.id in blacklist: + return await ctx.respond(":angry:", ephemeral=True) + + if message.is_system(): + return await ctx.respond("Dus jij wil system messages pinnen?\nMag niet.", ephemeral=True) + + await message.pin(reason=f"Didier Pin door {ctx.user.display_name}") + await ctx.respond("📌", ephemeral=True) + + +def setup(client: Didier): + # client.add_cog(SchoolCM(client)) + # TODO wait for bug to be fixed in lib then uncomment this + # when used in dm, tries to create a DM with the bot? + pass diff --git a/cogs/events.py b/cogs/events.py index 67abe79..7668d40 100644 --- a/cogs/events.py +++ b/cogs/events.py @@ -78,6 +78,12 @@ class Events(commands.Cog): # Earn XP & Message count stats.sentMessage(message) + @commands.Cog.listener() + async def on_thread_join(self, thread: discord.Thread): + # Join threads automatically + if thread.me is None: + await thread.join() + @commands.Cog.listener() async def on_command(self, ctx): """ diff --git a/cogs/school.py b/cogs/school.py index 520c87f..51066f2 100644 --- a/cogs/school.py +++ b/cogs/school.py @@ -82,7 +82,7 @@ class School(commands.Cog): 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=f"Didier Pin door {ctx.author.display_name}") await ctx.message.add_reaction("✅") @commands.command(name="Deadlines", aliases=["dl"])