Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 97f95fb

Browse files
authored
feat(sign_cafe): basic autothreading functionality (#429)
1 parent 0cf1416 commit 97f95fb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

bot/exts/sign_cafe.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from bot.database import store
2626
from bot.utils import did_you_mean, get_close_matches
2727
from bot.utils.datetimes import EASTERN, utcnow
28-
from bot.utils.discord import THEME_COLOR
28+
from bot.utils.discord import THEME_COLOR, display_name
2929
from bot.utils.gsheets import get_gsheet_client
3030
from bot.utils.ui import LinkView
3131

@@ -494,6 +494,7 @@ def make_role_table_age(self, guild: Guild):
494494
async def on_message(self, message: Message) -> None:
495495
if message.guild and message.guild.id != settings.SIGN_CAFE_GUILD_ID:
496496
return
497+
# Store when introductions were posted, for autokick functionality
497498
if message.channel.id == settings.SIGN_CAFE_INTRODUCTIONS_CHANNEL_ID:
498499
if await store.has_sign_cafe_intro(message.author.id):
499500
logger.debug(f"{message.author.id} already has intro")
@@ -504,6 +505,7 @@ async def on_message(self, message: Message) -> None:
504505
user_id=message.author.id,
505506
posted_at=message.created_at,
506507
)
508+
# Suggest using /top instead of -topic
507509
if message.content.strip() == "-topic":
508510
with suppress(disnake.errors.Forbidden):
509511
embed = disnake.Embed(
@@ -517,6 +519,12 @@ async def on_message(self, message: Message) -> None:
517519
color=disnake.Color.yellow(),
518520
)
519521
await message.author.send(embed=embed)
522+
# Autothreading
523+
if message.channel.id in settings.SIGN_CAFE_AUTOTHREAD_CHANNEL_IDS:
524+
await message.create_thread(
525+
name=f"{display_name(message.author)} - {message.created_at:%H·%M %b %d}",
526+
auto_archive_duration=disnake.ThreadArchiveDuration.day,
527+
)
520528

521529
@Cog.listener()
522530
async def on_member_remove(self, member: Member) -> None:

bot/settings.py

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
"SIGN_CAFE_ACKNOWLEDGED_RULES_ROLE_ID", required=False
4848
)
4949
SIGN_CAFE_BOT_CHANNEL_ID = env.int("SIGN_CAFE_BOT_CHANNEL_ID", required=False)
50+
SIGN_CAFE_AUTOTHREAD_CHANNEL_IDS = env.list(
51+
"SIGN_CAFE_AUTOTHREAD_CHANNEL_IDS", default=[], subcast=int
52+
)
5053
SIGN_CAFE_SKILL_ROLE_IDS = env.list("SIGN_CAFE_SKILL_ROLE_IDS", subcast=int)
5154
SIGN_CAFE_HEARING_SPECTRUM_ROLE_IDS = env.list(
5255
"SIGN_CAFE_HEARING_SPECTRUM_ROLE_IDS", subcast=int

0 commit comments

Comments
 (0)