This repository has been archived by the owner on May 10, 2024. It is now read-only.
forked from omar-elamin/TotalFreedomBot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchecks.py
133 lines (99 loc) · 3.4 KB
/
checks.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
from discord.ext import commands
class NoPermission(commands.MissingPermissions):
pass
class notAdminCommand(Exception):
def __init__(self,
message="The command you attempted does not exist or is not a whitelisted command for the adminconsole."):
self.message = message
super().__init__(self.message)
def is_staff():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id in [ctx.bot.admin, ctx.bot.senior_admin]:
return True
else:
raise NoPermission(['IS_STAFF_MEMBER'])
return commands.check(predicate)
def is_dev():
def predicate(ctx):
user = ctx.message.author
if user.id in ctx.bot.devs:
return True
else:
raise NoPermission(['BOT_DEVELOPER'])
return commands.check(predicate)
def is_mod_or_has_perms(**permissions):
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id in [ctx.bot.discord_mod, ctx.bot.discord_admin] or permissions and all(
getattr(ctx.channel.permissions_for(ctx.author), name, None) == value for name, value in
permissions.items()):
return True
else:
raise NoPermission(['IS_MOD_OR_HAS_PERMS'])
return commands.check(predicate)
def is_executive():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id in [ctx.bot.executive, ctx.bot.asst_exec]:
return True
else:
raise NoPermission(['IS_EXECUTIVE'])
return commands.check(predicate)
def is_tf_developer():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.developer:
return True
else:
raise NoPermission(['IS_TOTALFREEDOM_DEVELOPER'])
return commands.check(predicate)
def is_liaison():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.server_liaison:
return True
else:
raise NoPermission(['IS_SERVER_LIAISON'])
return commands.check(predicate)
def is_creative_designer():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.creative_designer:
return True
else:
raise NoPermission(['IS_CREATIVE_DESIGNER'])
return commands.check(predicate)
def is_smp_owner():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.smp_owner_id:
return True
else:
raise NoPermission(['IS_GMOD_OWNER'])
return commands.check(predicate)
def is_gmod_owner():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.gmod_owner_id:
return True
else:
raise NoPermission(['IS_GMOD_OWNER'])
return commands.check(predicate)
def is_senior():
def predicate(ctx):
user = ctx.message.author
for role in user.roles:
if role.id == ctx.bot.senior_admin:
return True
else:
raise NoPermission(['IS_SENIOR_ADMIN'])
return commands.check(predicate)