Automatically join threads, add placeholder code for pin context menu

pull/104/head
Stijn De Clercq 2022-02-10 19:34:40 +01:00
parent 93ede132a2
commit 9a999fb34b
3 changed files with 39 additions and 1 deletions

View File

@ -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

View File

@ -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):
"""

View File

@ -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"])