-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot_utils.py
33 lines (27 loc) · 873 Bytes
/
bot_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from calendar_utils import timedelta_message
from yaml import safe_load
configuration_file = open("configuration.yaml", "r")
configuration = safe_load(configuration_file.read())
TOKEN = configuration['token']
ROLES = configuration['roles']
CHANNELS = configuration['channels']
DISPLAY = configuration['display']
def contest_icon(contest):
try:
file = open(f"icons/{contest}.png", 'rb')
except FileNotFoundError:
return None
return file.read()
def mention_role(name):
if name is None:
return ''
identifier = name.lower().replace(' ', '')
if identifier not in ROLES:
return "@" + name
return f"<@&{ROLES[identifier]}>"
def arrow_to_timestamp(arrow):
unix = int(arrow.timestamp())
return f"<t:{unix}>"
def arrow_to_countdown(arrow):
unix = int(arrow.timestamp())
return f"<t:{unix}:R>"