diff --git a/misc.py b/misc.py index 07408d0..2c96881 100644 --- a/misc.py +++ b/misc.py @@ -63,34 +63,7 @@ class misc(commands.Cog): else: await interaction.response.send_message("You don't have permission in this context", ephemeral=True) - @nextcord.slash_command( - name="threadsummary", - description="Generate a list of created threads with the owner", - default_member_permissions=nextcord.Permissions(manage_messages=True), - ) - async def threadsummary(self, interaction: nextcord.Interaction): - if interaction.channel.type != nextcord.ChannelType.text: - await interaction.response.send_message("This is not a text channel", ephemeral=True) - return - message = f"Active threads in {interaction.channel.jump_url}\n" - for t in interaction.channel.threads: - if t.archived: - continue - message = message + f"<@{t.owner_id}>: {t.jump_url}\n" - await interaction.response.send_message(message, allowed_mentions=nextcord.AllowedMentions.none()) - - @commands.Cog.listener('on_thread_update') - async def threadupdatehandler(self, before: nextcord.Thread, after: nextcord.Thread): - pins = await after.parent.pins() - for t in pins: - if t.author.id == self.bot.application_id and t.content.split("\n")[0] == f"Active threads in {after.parent.jump_url}": - message = f"Active threads in {after.parent.jump_url}\n" - for p in after.parent.threads: - if p.archived: - continue - message = message + f"<@{p.owner_id}>: {p.jump_url}\n" - await t.edit(message) - return + def setup(bot: commands.Bot): diff --git a/rolesummary.py b/rolesummary.py new file mode 100644 index 0000000..d7a7fa8 --- /dev/null +++ b/rolesummary.py @@ -0,0 +1,70 @@ +import nextcord +from nextcord.ext import commands, application_checks +from nextcord import TextInputStyle +import traceback +import random +import aiosqlite as sqlite3 +import aiohttp +from urllib.parse import urlparse +import os +import sys + +class rolesummary(commands.Cog): + + def __init__(self, bot: commands.Bot): + self.bot = bot + + @nextcord.slash_command( + name="threadsummary", + description="Generate a list of created threads with the owner", + default_member_permissions=nextcord.Permissions(manage_messages=True), + ) + async def threadsummary(self, interaction: nextcord.Interaction): + if interaction.channel.type != nextcord.ChannelType.text: + await interaction.response.send_message("This is not a text channel", ephemeral=True) + return + message = f"Active threads in {interaction.channel.jump_url}\n" + for t in interaction.channel.threads: + if t.archived: + continue + message = message + f"<@{t.owner_id}>: {t.jump_url}\n" + await interaction.response.send_message(message, allowed_mentions=nextcord.AllowedMentions.none()) + + @commands.Cog.listener('on_thread_update') + async def threadupdatehandler(self, before: nextcord.Thread, after: nextcord.Thread): + pins = await after.parent.pins() + for t in pins: + if t.author.id == self.bot.application_id and t.content.split("\n")[0] == f"Active threads in {after.parent.jump_url}": + message = f"Active threads in {after.parent.jump_url}\n" + for p in after.parent.threads: + if p.archived: + continue + message = message + f"<@{p.owner_id}>: {p.jump_url}\n" + await t.edit(message) + return + + @commands.Cog.listener('on_thread_create') + async def threadupdatehandler(self, thread: nextcord.Thread): + pins = await thread.parent.pins() + for t in pins: + if t.author.id == self.bot.application_id and t.content.split("\n")[0] == f"Active threads in {thread.parent.jump_url}": + message = f"Active threads in {thread.parent.jump_url}\n" + for p in thread.parent.threads: + if p.archived: + continue + message = message + f"<@{p.owner_id}>: {p.jump_url}\n" + await t.edit(message) + return + + @commands.Cog.listener('on_thread_delete') + async def threadupdatehandler(self, thread: nextcord.Thread): + pins = await thread.parent.pins() + for t in pins: + if t.author.id == self.bot.application_id and t.content.split("\n")[0] == f"Active threads in {thread.parent.jump_url}": + message = f"Active threads in {thread.parent.jump_url}\n" + for p in thread.parent.threads: + if p.archived: + continue + message = message + f"<@{p.owner_id}>: {p.jump_url}\n" + await t.edit(message) + return \ No newline at end of file