Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions bot/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dataclasses
import enum
from calendar import Month
from datetime import UTC, datetime
from os import environ

Expand Down Expand Up @@ -109,31 +109,6 @@ class _Categories(EnvConfig, env_prefix="CATEGORY_"):
Categories = _Categories()


class Month(enum.IntEnum):
"""
Enum lookup between Months & month numbers.

Can bre replaced with the below when upgrading to 3.12
https://docs.python.org/3/library/calendar.html#calendar.Month
"""

JANUARY = 1
FEBRUARY = 2
MARCH = 3
APRIL = 4
MAY = 5
JUNE = 6
JULY = 7
AUGUST = 8
SEPTEMBER = 9
OCTOBER = 10
NOVEMBER = 11
DECEMBER = 12

def __str__(self) -> str:
return self.name.title()


class _Bot(EnvConfig, env_prefix="BOT_"):
name: str = "Sir Robin"
guild: int = 267624335836053506
Expand Down
2 changes: 1 addition & 1 deletion bot/exts/advent_of_code/_cog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from calendar import Month
from datetime import UTC, datetime, timedelta
from pathlib import Path

Expand All @@ -15,7 +16,6 @@
Channels,
Colours,
Emojis,
Month,
Roles,
WHITELISTED_CHANNELS,
)
Expand Down
5 changes: 3 additions & 2 deletions bot/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import asyncio
import re
import string
from calendar import Month
from collections.abc import Iterable
from datetime import UTC, datetime

import discord
from discord.ext.commands import BadArgument, Context

from bot.constants import Bot, Month
from bot.constants import Bot
from bot.utils.pagination import LinePaginator


def human_months(months: Iterable[Month]) -> str:
"""Build a comma separated list of `months`."""
return ", ".join(str(m) for m in months)
return ", ".join(m.name.title() for m in months)


def resolve_current_month() -> Month:
Expand Down
3 changes: 2 additions & 1 deletion bot/utils/decorators.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import asyncio
import functools
from calendar import Month
from collections.abc import Callable, Container

from discord.ext import commands
from discord.ext.commands import Command, Context
from pydis_core.utils import logging

from bot.constants import Channels, Month
from bot.constants import Channels
from bot.utils import human_months, resolve_current_month
from bot.utils.checks import in_whitelist_check
from bot.utils.exceptions import InMonthCheckFailure, SilentRoleFailure
Expand Down