mirror of https://github.com/stijndcl/didier
Automatically join threads, add placeholder code for pin context menu
parent
93ede132a2
commit
9a999fb34b
|
@ -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
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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"])
|
||||
|
|
Loading…
Reference in New Issue