Update
This commit is contained in:
parent
2761a863ef
commit
56a7f9c602
2 changed files with 71 additions and 28 deletions
29
misc.py
29
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):
|
||||
|
|
70
rolesummary.py
Normal file
70
rolesummary.py
Normal file
|
@ -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
|
Loading…
Reference in a new issue