-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.py
196 lines (134 loc) · 5.62 KB
/
stats.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import discord
import json
from config import *
async def stats(ctx, client):
echoRole = discord.utils.find(lambda r: r.name == '☄️', ctx.guild.roles)
elysiumRole = discord.utils.find(lambda r: r.name == '🌑', ctx.guild.roles)
solarisRole = discord.utils.find(lambda r: r.name == '🌕', ctx.guild.roles)
atharaRole = discord.utils.find(lambda r: r.name == '🌌', ctx.guild.roles)
novaRole = discord.utils.find(lambda r: r.name == '🪐', ctx.guild.roles)
mainRole = discord.utils.find(lambda r: r.name == '🚀', ctx.guild.roles)
nebulaRole = discord.utils.find(lambda r: r.name == '✨', ctx.guild.roles)
allRole = discord.utils.find(lambda r: r.name == '🍿', ctx.guild.roles)
moderator_role_white_list = ['Модератор', 'Младший Модератор', 'Старший Модератор']
with open("basa.json", "r") as file:
profile = json.load(file)
embedEcho = discord.Embed(
colour=discord.Colour(0x00FFFF),
title='Статистика Эхо модераторов'
)
embedElysium = discord.Embed(
colour=discord.Colour(0x808080),
title='Статистика Элизиум модераторов'
)
embedSolaris = discord.Embed(
colour=discord.Colour(0xF8FF00),
title='Статистика Солярис модераторов'
)
embedAthara = discord.Embed(
colour=discord.Colour(0xC485F7),
title='Статистика Атара модераторов'
)
embedNova = discord.Embed(
colour=discord.Colour(0xFFA500),
title='Статистика Нова модераторов'
)
embedMain = discord.Embed(
colour=discord.Colour(0xFF0000),
title='Статистика Мейн модераторов'
)
embedNebula = discord.Embed(
colour=discord.Colour(0xFF8C00),
title='Статистика Небула модераторов'
)
embedAllRole = discord.Embed(
colour=discord.Colour(0xFFFFFF),
title='Статистика модераторов без прикрипленого сервера'
)
guild = client.get_guild(GUILD)
members = {}
for x in guild.members:
id = x.id
name = x.name
members[id] = {"name": '', "server": ''}
newName = members['name'] = name
members[id]['name'] = newName
if echoRole in x.roles:
newServer = members['server'] = 'echo'
members[id]['server'] = newServer
with open("basa.json", "r") as file:
profile = json.load(file)
def takeStats(x, text=None):
x = profile.get(x)
ban = x['ban']
warn = x['warn']
report = x['report']
try:
ahelp = x['ahelp']
except:
ahelp = 0
try:
ckey = x['ckey']
except:
ckey = '-'
if int(ban) + int(warn) + int(report) != 0:
ban = 'Баны: ' +str(ban)
warn = 'Варны: ' + str(warn)
report = 'Жалобы: ' + str(report)
ahelp = 'Ахелпы: ' + str(ahelp)
ckey = 'Сикей: ' + str(ckey)
li = []
li.append(ban)
li.append(warn)
li.append(report)
li.append(ahelp)
li.append(ckey)
text = ''
for x in li:
text += x + '\n'
return text
else:
ban = 'Баны: 0'
warn = 'Варны: 0'
report = 'Жалобы: 0'
ahelp = 'Ахелпы: 0'
ckey = 'Сикей: -'
li = []
li.append(ban)
li.append(warn)
li.append(report)
li.append(ahelp)
li.append(ckey)
text = ''
for x in li:
text += x + '\n'
return text
for x in profile:
id = x
for y in guild.members:
try:
id = int(id)
except:
id = 0
if y.id == id:
y: discord.Member
for role in y.roles:
if role not in moderator_role_white_list:
continue
if echoRole in y.roles:
embedEcho.add_field(name=f'{y.name}', value=takeStats(x))
elif solarisRole in y.roles:
embedSolaris.add_field(name=f'{y.name}', value=takeStats(x))
elif novaRole in y.roles:
embedNova.add_field(name=f'{y.name}', value=takeStats(x))
elif atharaRole in y.roles:
embedAthara.add_field(name=f'{y.name}', value=takeStats(x))
elif elysiumRole in y.roles:
embedElysium.add_field(name=f'{y.name}', value=takeStats(x))
elif allRole in y.roles:
embedAllRole.add_field(name=f'{y.name}', value=takeStats(x))
elif mainRole in y.roles:
embedMain.add_field(name=f'{y.name}', value=takeStats(x))
elif nebulaRole in y.roles:
embedNebula.add_field(name=f'{y.name}', value=takeStats(x))
return embedEcho, embedSolaris, embedNova, embedAthara, embedElysium, embedAllRole, embedMain, embedNebula