From 5adbdd6d9fc10faae0e5362e1494d9c80433f177 Mon Sep 17 00:00:00 2001 From: kwzrd Date: Sat, 22 Feb 2020 20:14:57 +0100 Subject: Add IntEnum for the 12 months This is a safe way to specify which months a command can be used in. The enum's values behave as ints when being passed to the datetime.date initialiser. --- bot/constants.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'bot/constants.py') diff --git a/bot/constants.py b/bot/constants.py index f0656926..2e4b4369 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -1,11 +1,12 @@ +import enum import logging +from datetime import datetime from os import environ from typing import NamedTuple -from datetime import datetime __all__ = ( "bookmark_icon_url", - "AdventOfCode", "Channels", "Client", "Colours", "Emojis", "Hacktoberfest", "Roles", "Tokens", + "AdventOfCode", "Channels", "Client", "Colours", "Emojis", "Hacktoberfest", "Month", "Roles", "Tokens", "WHITELISTED_CHANNELS", "STAFF_ROLES", "MODERATION_ROLES", "POSITIVE_REPLIES", "NEGATIVE_REPLIES", "ERROR_REPLIES", ) @@ -112,6 +113,21 @@ class Hacktoberfest(NamedTuple): voice_id = 514420006474219521 +class Month(enum.IntEnum): + january = 1 + february = 2 + march = 3 + april = 4 + may = 5 + june = 6 + july = 7 + august = 8 + september = 9 + october = 10 + november = 11 + december = 12 + + class Roles(NamedTuple): admin = int(environ.get("SEASONALBOT_ADMIN_ROLE_ID", 267628507062992896)) announcements = 463658397560995840 -- cgit v1.2.3