generated from kkrypt0nn/Python-Discord-Bot-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.py
89 lines (76 loc) · 2.49 KB
/
check.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from typing import TypeVar, Callable
from discord.ext import commands
from utils.exceptions import *
from utils.classes.Const import config
T = TypeVar("T")
def is_owner() -> Callable[[T], T]:
"""
Проверка что пользователь является создателем бота
"""
async def predicate(context: commands.Context) -> bool:
try:
if context.author.id not in config.owners:
raise UserNotOwner
except UserNotOwner as e:
print(e)
return False
return True
return commands.check(predicate)
def is_admin() -> Callable[[T], T]:
"""
Проверка что пользователь является администратором бота
"""
async def predicate(context: commands.Context) -> bool:
try:
if context.author.id not in config.admins:
raise UserNotAdmin
except UserNotAdmin as e:
print(e)
return False
return True
return commands.check(predicate)
def is_samuro_dev() -> Callable[[T], T]:
'''
Проверка налачия роли Samuro_dev
'''
async def predicate(context: commands.Context) -> bool:
good_roles = [
959144584720580618, # Samuro_dev
274543866743357442, # Stalk admin
880865537058545686, # test
]
flag = False
for role in context.author.roles:
if role.id in good_roles:
flag = True
try:
if not flag:
raise UserNotAdmin
except UserNotAdmin as e:
print(e)
return flag
return commands.check(predicate)
def is_lead() -> Callable[[T], T]:
"""
Проверка наличия роли ведущего
"""
async def predicate(context: commands.Context) -> bool:
good_roles = [
959144584720580618, # Samuro_dev
789084039180451840, # Ведущий
880865537058545686, # test
274543866743357442, # Stalk admin
961241562036174858, # 5x5 admin
972888717574414366, # Букмекер
]
flag = False
for role in context.author.roles:
if role.id in good_roles:
flag = True
try:
if not flag:
raise UserNotAdmin
except UserNotAdmin as e:
print(e)
return flag
return commands.check(predicate)