diff options
Diffstat (limited to 'bot/utils/__init__.py')
-rw-r--r-- | bot/utils/__init__.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bot/utils/__init__.py b/bot/utils/__init__.py index cb5c9fbe..69bff4de 100644 --- a/bot/utils/__init__.py +++ b/bot/utils/__init__.py @@ -2,14 +2,29 @@ import asyncio import contextlib import re import string +from datetime import datetime from typing import List import discord from discord.ext.commands import BadArgument, Context +from bot.constants import Client, Month from bot.utils.pagination import LinePaginator +def resolve_current_month() -> Month: + """ + Determine current month w.r.t. `Client.month_override` env var. + + If the env variable was set, current month always resolves to the configured value. + Otherwise, the current UTC month is given. + """ + if Client.month_override is not None: + return Month(Client.month_override) + else: + return Month(datetime.utcnow().month) + + async def disambiguate( ctx: Context, entries: List[str], *, timeout: float = 30, entries_per_page: int = 20, empty: bool = False, embed: discord.Embed = None |