Skip to content

Commit

Permalink
Remove extraneous print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz committed Feb 11, 2024
1 parent 5e1b1ce commit 89ca33a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/calendar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import datetime
import logging
import time
from dataclasses import dataclass
from enum import Enum
Expand Down Expand Up @@ -28,6 +29,9 @@
from .bot import MILBot


logger = logging.getLogger(__name__)


class EventType(Enum):
GBM = "[GBM]"
SUBTEAM = "[SUBTEAM]"
Expand Down Expand Up @@ -84,7 +88,6 @@ def from_ical_event(cls, event: icalendar.Event, team: Team):
)

def embed_str(self) -> str:
print(self.title, self.team, self.team.emoji)
return f"{self.team.emoji} {self.type.emoji()} {discord.utils.format_dt(self.start, 't')} - {discord.utils.format_dt(self.end, 't')}: **{self.title}**"


Expand All @@ -94,11 +97,11 @@ def __init__(self, url: str):

@property
def ics_url(self) -> str:
return f"{self.url}/calendar.ics"
return f"{self.url}/calendar.ics" if self.url else ""

@property
def html_url(self) -> str:
return f"{self.url}/calendar.html"
return f"{self.url}/calendar.html" if self.url else ""


class CalendarView(discord.ui.View):
Expand Down Expand Up @@ -176,6 +179,9 @@ def __init__(self, bot: MILBot):
self.calendar.start()

async def load_calendar(self, url: str, team: Team) -> list[Event]:
if not url:
logger.warn("Calendar URL is empty, not loading this calendar.")
return []
response = await self.bot.session.get(url)
self.ics = icalendar.Calendar.from_ical(await response.read())
today = datetime.date.today()
Expand Down Expand Up @@ -282,8 +288,6 @@ async def calendar(self):
text=f"Last refreshed: {date_formatted} (took: {time_taken:.2f}s)",
)
last_message = [m async for m in channel.history(limit=1, oldest_first=True)]
for field in embed.fields:
print(field.name, len(field.value) if field.value else 0)
if not last_message:
await channel.send(embed=embed, view=CalendarView(self.bot))
else:
Expand Down

0 comments on commit 89ca33a

Please sign in to comment.