Skip to content

Commit

Permalink
Various tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
trickeydan committed Nov 29, 2023
1 parent ac4e81e commit 3d74246
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions kmibot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PubInfo(BaseModel):

class PubConfig(BaseModel):
pubs: list[PubInfo]
supplemental_emoji: str = "🍺"
channel_id: int
description: str
weekday: int
Expand Down
4 changes: 2 additions & 2 deletions kmibot/modules/pub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ..module import Module
from .commands import PubCommand
from .utils import get_pub_buttons_view
from .utils import event_is_pub, get_pub_buttons_view

if TYPE_CHECKING:
from kmibot.client import DiscordClient
Expand All @@ -25,7 +25,7 @@ async def on_scheduled_event_update(
old_event: discord.ScheduledEvent,
new_event: discord.ScheduledEvent,
) -> None:
if "Pub" in new_event.name:
if event_is_pub(new_event):
await self.handle_pub_event_change(client, old_event, new_event)

async def handle_pub_event_change(
Expand Down
5 changes: 3 additions & 2 deletions kmibot/modules/pub/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def _create_pub_event(
) -> discord.ScheduledEvent:
LOGGER.info(f"Creating scheduled event at {start_time}")
return await guild.create_scheduled_event(
name=f"{pub.emoji} {title} {pub.emoji}",
name=f"{pub.emoji} {title} {self.config.pub.supplemental_emoji}",
start_time=start_time,
end_time=start_time + timedelta(hours=3),
entity_type=discord.EntityType.external,
Expand Down Expand Up @@ -115,12 +115,13 @@ async def next(self, interaction: discord.Interaction) -> None: # noqa: A003
)

LOGGER.info(f"Posting pub info in {pub_channel}")
formatted_pub_name = f"{pub.emoji} **{pub.name}** {self.config.pub.supplemental_emoji}"
await pub_channel.send(
"\n".join(
[
"**Pub Next Week**",
f"The next pub will be <t:{int(pub_time.timestamp())}:R>",
f"It will be held at {pub.emoji} **{pub.name}** {pub.emoji}",
f"It will be held at {formatted_pub_name}",
"",
"If you are coming, please mark 🔔 interest on the event!",
],
Expand Down

0 comments on commit 3d74246

Please sign in to comment.