-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.py
34 lines (26 loc) · 1.13 KB
/
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
34
def is_author_game_creator(context, room):
author = context.author
return author.id == list(room.keys())[0]
def is_author_bunker_admin(context):
author = context.author
return any(r.name == 'Bunker admin' for r in author.guild.roles)
def filter_players_not_in_room(room):
def double_wrap(func):
async def wrap(context, *args, **kwargs):
users_in_room = []
for user_mention in args:
user_id = convert_mention_to_user_id(user_mention)
if user_id in room:
users_in_room.append(user_mention)
else:
await context.send(f"Error, {user_mention} not in room")
return await func(context, *users_in_room, **kwargs)
return wrap
return double_wrap
def convert_mentions_to_user_ids(func):
async def wrap(context, *args, **kwargs):
user_ids = tuple(convert_mention_to_user_id(user_mention) for user_mention in args)
return await func(context, *user_ids, **kwargs)
return wrap
def convert_mention_to_user_id(mention):
return int(mention.replace('<@!', '').replace('>', ''))