Skip to content

Commit

Permalink
Merge pull request #30 from juniorguru/honzajavorek/fix-naming
Browse files Browse the repository at this point in the history
Fix naming threads
  • Loading branch information
honzajavorek authored Sep 25, 2023
2 parents 1e12025 + 550413e commit 3425aa1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 4 additions & 4 deletions juniorguru_chick/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from discord.ext import commands

from juniorguru_chick.lib import intro
from juniorguru_chick.lib.threads import is_thread_created, fetch_starting_message, create_thread, ensure_thread_name, add_members_with_role
from juniorguru_chick.lib.threads import is_thread_created, fetch_starting_message, ensure_thread_name, add_members_with_role, name_thread


logger = logging.getLogger("chick.bot")
Expand Down Expand Up @@ -48,11 +48,11 @@ async def on_message(message: discord.Message) -> None:
logger.info(f"Message sent to {channel_name!r}")

if channel_name == "ahoj":
await create_thread(message, intro.THREAD_NAME_TEMPLATE)
await message.create_thread(name=name_thread(message, intro.THREAD_NAME_TEMPLATE))
elif channel_name == "past-vedle-pasti":
await create_thread(message, "{weekday} past na {author}", "Past na {author}: {name}")
await message.create_thread(name=name_thread(message, "{weekday} past na {author}", "Past na {author}: {name}"))
elif channel_name == "můj-dnešní-objev":
await create_thread(message, "{weekday} objev od {author}", "Objev od {author}: {name}")
await message.create_thread(name=name_thread(message, "{weekday} objev od {author}", "Objev od {author}: {name}"))


@bot.event
Expand Down
4 changes: 0 additions & 4 deletions juniorguru_chick/lib/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ def name_thread(message: discord.Message, name_template, alternative_name_templa
name = name_template.format(weekday=DAYS[weekday], author=message.author.display_name)
return name

async def create_thread(message: discord.Message, name_template) -> discord.Thread:
"""Creates a new thread for given message"""
name = name_thread(message, name_template)
return await message.create_thread(name=name)

async def ensure_thread_name(thread: discord.Thread, name_template) -> str | None:
"""Ensures given thread has a name"""
Expand Down

0 comments on commit 3425aa1

Please sign in to comment.