-
Notifications
You must be signed in to change notification settings - Fork 1
/
clans.py
1787 lines (1672 loc) · 96.9 KB
/
clans.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import requests
import time
import disnake
from pymongo import MongoClient
import pymongo
from disnake import File, ButtonStyle
from disnake.ui import Button, View
from disnake import components
from PIL import Image, ImageChops, ImageDraw, ImageFont
import io
import asyncio
from io import BytesIO
import time
import random
from datetime import datetime, timedelta
from datetime import date
from delorean import Delorean
import disnake
import config
from config import *
from disnake.ext import commands, tasks
import os
bot = commands.Bot(command_prefix="!", intents=disnake.Intents.all())
bot.remove_command('help')
test_guild = 1112739235741573152
client = pymongo.MongoClient(
"mongodb+srv://clans:clans@clans.fi8pc3i.mongodb.net/?retryWrites=true&w=majority")
coll = client.lan.balance
m = client.lan.balance
tr = client.lan.transiction
mar = client.lan.lhistory
loves = client.lan.loves
clans = client.lan.clans
async def fu(interaction):
embed = disnake.Embed(
description=f"{interaction.user.mention}, Вы **не можете** использовать данную **кнопку.**", color=0x2F3136)
await interaction.send(embed=embed, ephemeral=True)
class ButtonPaginato:
def __init__(
self,
segments,
title="",
color=0x000000,
prefix="",
suffix="",
target_page=1,
timeout=300,
button_style=disnake.ButtonStyle.gray,
invalid_user_function=fu,
):
self.embeds = []
self.current_page = target_page
self.timeout = timeout
self.button_style = button_style
self.invalid_user_function = invalid_user_function
for segment in segments:
if isinstance(segment, disnake.Embed):
self.embeds.append(segment)
else:
x = disnake.Embed(title=title, color=color,
description=prefix + segment)
x.set_thumbnail(url=suffix)
self.embeds.append(x)
if self.current_page > len(segments) or self.current_page < 1:
self.current_page = 1
class PaginatorView(disnake.ui.View):
def __init__(this, interaction):
super().__init__()
this.timeout = self.timeout
this.interaction = interaction
async def on_timeout(this):
for button in this.children:
button.disabled = True
await this.interaction.edit_original_message(embed=self.embeds[self.current_page-1], view=this)
return await super().on_timeout()
def update_page(this):
for button in this.children:
if button.label:
if button.label.strip() != "":
button.label = f"Страница {self.current_page}/{len(self.embeds)}"
@disnake.ui.button(emoji="<:left:1048306852691202058>", style=self.button_style, disabled=True if len(self.embeds) == 1 else False)
async def previous_button(this, _, button_interaction):
if button_interaction.user != this.interaction.user:
await self.invalid_user_function(button_interaction)
return
self.current_page -= 1
if self.current_page < 1:
self.current_page = int(1)
this.update_page()
await button_interaction.response.edit_message(embed=self.embeds[self.current_page-1], view=this)
@disnake.ui.button(emoji="<:trash:1048306861478264863>", style=disnake.ButtonStyle.grey)
async def previous_buttons(this, _, button_interaction):
if button_interaction.author != this.interaction.author:
await self.invalid_user_function(button_interaction)
return
await this.interaction.delete_original_message()
@disnake.ui.button(emoji="<:right:1048306859628564520>", style=self.button_style, disabled=True if len(self.embeds) == 1 else False)
async def next_button(this, _, button_interaction):
if button_interaction.user != this.interaction.user:
await self.invalid_user_function(button_interaction)
return
self.current_page += 1
if self.current_page > len(self.embeds):
self.current_page = len(self.embeds)
this.update_page()
await button_interaction.response.edit_message(embed=self.embeds[self.current_page-1], view=this)
self.view = PaginatorView
async def start(self, interaction, ephemeral=False, deferred=False):
if not deferred:
await interaction.response.send_message(embed=self.embeds[self.current_page-1], view=self.view(interaction), ephemeral=ephemeral)
else:
await interaction.edit_original_message(embed=self.embeds[self.current_page-1], view=self.view(interaction))
async def return_mesto(member_id):
finds = clans.find(limit=2000).sort("online", -1)
finds = list(finds)
try:
if finds:
find = clans.find_one({"owner_id": member_id})
if find:
index = finds.index(find)+1
if index > 1000:
return index
else:
return index
else:
return index
else:
return 'Ошибка'
except:
return '100'
def circle(pfp, size=(250, 250)):
pfp = pfp.resize(size, Image.ANTIALIAS).convert("RGBA")
bigsize = (pfp.size[0] * 3, pfp.size[1] * 3)
mask = Image.new('L', bigsize, 0)
draw = ImageDraw.Draw(mask)
draw.ellipse((0, 0) + bigsize, fill=255)
mask = mask.resize(pfp.size, Image.ANTIALIAS)
mask = ImageChops.darker(mask, pfp.split()[- 1])
pfp.putalpha(mask)
return pfp
async def get_mem(members, interaction):
try:
uid = str(members).split("@")[1].split(">")[0]
except:
uid = members
member = interaction.guild.get_member(uid)
return member
def circle(pfp, size=(250, 250)):
pfp = pfp.resize(size, Image.ANTIALIAS).convert("RGBA")
bigsize = (pfp.size[0] * 3, pfp.size[1] * 3)
mask = Image.new('L', bigsize, 0)
draw = ImageDraw.Draw(mask)
draw.ellipse((0, 0) + bigsize, fill=255)
mask = mask.resize(pfp.size, Image.ANTIALIAS)
mask = ImageChops.darker(mask, pfp.split()[- 1])
pfp.putalpha(mask)
return pfp
class clan_button_back(disnake.ui.View):
def __init__(self, find, bot, member: disnake.Member):
self.find = find
self.bot = bot
self.member = member
super().__init__(timeout=None)
@disnake.ui.button(label="Назад", style=ButtonStyle.gray)
async def bu1(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
role = interaction.guild.get_role(self.find['role'])
emb = disnake.Embed(
title=f'Управление Кланом — {self.find["room_name"]}',
description=f'Дата создания: <t:{self.find["time_create"]}:F>\nСлоты: **{len(role.members)} / 30**\nСоздатель: <@{self.find["owner_id"]}>\nРоль: <@&{self.find["role"]}>', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.response.edit_message(embed=emb, view=clan_button(self.find, self.bot, self.member))
class clan_button2(disnake.ui.View):
def __init__(self, find, bot, member: disnake.Member):
self.find = find
self.bot = bot
self.member = member
super().__init__(timeout=None)
@disnake.ui.button(label="Пригласить в клан", style=ButtonStyle.gray, row=1)
async def bu1(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
role = interaction.guild.get_role(self.find['role'])
if len(role.members) >= 30:
embed = disnake.Embed(title="Пригласить в клан", description=f"{interaction.author.mention}, **превышен** лимит **участников**.", color=0x2f3136).set_thumbnail(
url=interaction.author.display_avatar)
await interaction.response.edit_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
else:
emb = disnake.Embed(
title='Пригласить участника в клан',
description=f'{interaction.author.mention}, **упомяните** пользователя.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.response.edit_message(embed=emb, view=None)
try:
res = await self.bot.wait_for("message", check=lambda i: i.author == interaction.author, timeout=60)
await res.delete()
id_mem = res.content \
.replace("<", "") \
.replace("@", "") \
.replace("!", "") \
.replace(">", "")
try:
member = await interaction.guild.fetch_member(int(id_mem))
except:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
raise
if member.bot:
embed = disnake.Embed(title="Пригласить участника в клан",
description=f"{interaction.author.mention}, Вы **не можете** провести **данную** операцию с **ботом...** ", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
if member == interaction.author:
embed = disnake.Embed(title="Пригласить участника в клан",
description=f"{interaction.author.mention}, Вы **не можете** пригласить **сами у себя**.", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
channel = interaction.guild.get_channel(
int(self.find['channel']))
if member:
role = interaction.guild.get_role(self.find['role'])
if role in member.roles:
emb = disnake.Embed(
title='Пригласить участника в клан',
description=f'{interaction.author.mention}, у {member.mention} **уже есть** роль клана <#{self.find["channel"]}>', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
else:
post = {
"id": member.id,
"online": 0,
"pair": "Отсутствует",
"clan": "Отсутствует",
"balance": 0,
"rooms": [],
"clan_room_id": 0,
"message": 0,
"status": "Отсутствует"
}
if coll.count_documents({"id": member.id}) == 0:
coll.insert_one(post)
if int(m.find_one({"id": member.id})['clan_room_id']) != 0:
emb = disnake.Embed(
title='Пригласить участника в клан',
description=f'{interaction.author.mention}, у {member.mention} **уже есть** роль клана <#{self.find["channel"]}>', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
else:
emb = disnake.Embed(
title='Пригласить участника в клан',
description=f'{interaction.author.mention}, {member.mention} **был** успешно **приглашен** в клан <#{self.find["channel"]}>', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
#print(self.find["channel"])
clanch = self.bot.get_channel(self.find["channel"])
#print(clanch.name)
coll.update_one({"id": member.id}, {"$set": {"clan": clanch.name, "clan_room_id": channel.id}})
await member.add_roles(role)
await channel.set_permissions(member, connect=True, view_channel=True)
else:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
except asyncio.TimeoutError:
emb = disnake.Embed(
title='Пригласить участника в клан',
description=f'{interaction.author.mention}, время **вышло**!', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
msg = await interaction.response.edit_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
@disnake.ui.button(label="Исключить из клана", style=ButtonStyle.gray, row=1)
async def bu12(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
channel = interaction.guild.get_channel(int(self.find['channel']))
emb = disnake.Embed(
title='Исключить из клана',
description=f'{interaction.author.mention}, **упомяните** пользователя.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
msg = await interaction.response.edit_message(embed=emb, view=None)
try:
res = await self.bot.wait_for("message", check=lambda i: i.author == interaction.author, timeout=60)
await res.delete()
id_mem = res.content \
.replace("<", "") \
.replace("@", "") \
.replace("!", "") \
.replace(">", "")
try:
member = await interaction.guild.fetch_member(int(id_mem))
except:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
raise
if member:
if member.bot:
embed = disnake.Embed(
title="Исключить из клана", description=f"{interaction.author.mention}, Вы **не можете** провести **данную** операцию с **ботом...** ", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
if member == interaction.author:
embed = disnake.Embed(
title="Исключить из клана", description=f"{interaction.author.mention}, Вы **не можете** исключить **сами себя**.", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
role = interaction.guild.get_role(self.find['role'])
if role in member.roles:
emb = disnake.Embed(
title='Исключить из клана',
description=f'{interaction.author.mention}, {member.mention} **Был** успешно **исключен** из клана <#{channel.id}>', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
embm = disnake.Embed(
title = "Уведомление",
description = f"{member.mention}, вы были исключены из клана **{role.name}** пользователем {interaction.author.mention}",
color = 0x2f3136
)
embm.set_thumbnail(url=member.display_avatar)
await member.send(embed=emb)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
await channel.set_permissions(member, connect=False, view_channel=False)
coll.update_one({"id": member.id}, {
"$set": {"clan_room_id": 0}})
for i in clans.find({"manage_id": member.id, "guild_id": interaction.guild.id, "prava": 1}):
clans.delete_one(i)
try:
await member.remove_roles(role)
except:
pass
else:
embed = disnake.Embed(
title="Исключить из клана", description=f"{interaction.author.mention}, **Не** состоит в **вашем** клане. ", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
else:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await msg.edit(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
except asyncio.TimeoutError:
emb = disnake.Embed(
title='Исключить из клана',
description=f'{interaction.author.mention}, время **вышло**!', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await msg.edit(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
@disnake.ui.button(label="Добавить совладельца", style=ButtonStyle.gray, disabled=True, row=1)
async def bu122(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
channel = interaction.guild.get_channel(int(self.find['channel']))
okss = []
for i in clans.find({"channel": channel.id, "prava": 1}):
okss.append(i)
if len(okss) == 1:
emb = disnake.Embed(
title='Добавить совладельца',
description=f'{interaction.author.mention}, **Вы** превысили **лимит** совладельцов.', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.response.edit_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
return
emb = disnake.Embed(
title='Добавить совладельца',
description=f'{interaction.author.mention}, **упомяните** пользователя.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.response.edit_message(embed=emb, components=[])
try:
res = await self.bot.wait_for("message", check=lambda i: i.author == interaction.author, timeout=60)
await res.delete()
id_mem = res.content \
.replace("<", "") \
.replace("@", "") \
.replace("!", "") \
.replace(">", "")
try:
member = await interaction.guild.fetch_member(int(id_mem))
except:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
raise
if member:
if member.bot:
embed = disnake.Embed(
title="Добавить совладельца", description=f"{interaction.author.mention}, Вы **не можете** провести **данную** операцию с **ботом...** ", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
if member == interaction.author:
embed = disnake.Embed(
title="Добавить совладельца", description=f"{interaction.author.mention}, Вы **не можете** добавить **сами себя**.", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
role = interaction.guild.get_role(self.find['role'])
if role in member.roles:
finds = clans.find_one(
{"guild_id": member.guild.id, "prava": 1, "room_name": self.find['room_name']})
if finds:
emb = disnake.Embed(
title='Добавить совладельца',
description=f'{interaction.author.mention}, пользователь {member.mention} уже является **СоВладельцем** в клане <#{channel.id}>', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
else:
emb = disnake.Embed(
title='Добавить совладельца',
description=f'{interaction.author.mention}, вы **выдали** пользователю {member.mention} **СоВладельца** в клане <#{channel.id}>', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
oks = []
for i in clans.find({"manage_id": member.id, "guild_id": interaction.guild.id}):
oks.append(i)
zx = len(oks)
post = {
"manage_id": member.id,
"prava": 1,
"channel": channel.id,
"role": role.id,
"guild_id": interaction.guild.id,
"counte": zx + 1,
"room_name": self.find['room_name']
}
clans.insert_one(post)
else:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
msg = await interaction.response.edit_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
except asyncio.TimeoutError:
emb = disnake.Embed(
title='Добавить совладельца',
description=f'{interaction.author.mention}, время **вышло**!', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
msg = await interaction.response.edit_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
@disnake.ui.button(label="Удалить совладельца", style=ButtonStyle.gray, disabled=True, row=2)
async def bu1222(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
channel = interaction.guild.get_channel(int(self.find['channel']))
emb = disnake.Embed(
title='Удалить совладельца',
description=f'{interaction.author.mention}, **упомяните** пользователя.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
msg = await interaction.response.edit_message(embed=emb, view=None)
try:
res = await self.bot.wait_for("message", check=lambda i: i.author == interaction.author, timeout=60)
await res.delete()
num1 = self.find
self.l_room = clans
id_mem = res.content \
.replace("<", "") \
.replace("@", "") \
.replace("!", "") \
.replace(">", "")
try:
member = await interaction.guild.fetch_member(int(id_mem))
except:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
raise
if member:
if member.bot:
embed = disnake.Embed(
title="Удалить совладельца", description=f"{interaction.author.mention}, Вы **не можете** провести **данную** операцию с **ботом...** ", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
if member == interaction.author:
embed = disnake.Embed(
title="Удалить совладельца", description=f"{interaction.author.mention}, Вы **не можете** удалить **сами себя**.", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
role = interaction.guild.get_role(num1['role'])
if role in member.roles:
finds = self.l_room.find_one(
{"manage_id": member.id, "guild_id": interaction.guild.id, "prava": 1})
if not finds:
emb = disnake.Embed(
title='Удалить совладельца',
description=f'{interaction.author.mention}, пользователь {member.mention} **не** является **СоВладельцем** в клане <#{channel.id}>', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
else:
emb = disnake.Embed(
title='Удалить совладельца',
description=f'{interaction.author.mention}, вы **удалили** с пользователя {member.mention} **СоВладельца** в клане <#{channel.id}>', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
self.l_room.delete_one(finds)
else:
emb = disnake.Embed(
title='Удалить совладельца',
description=f'{interaction.author.mention}, **Не** состоит в **клане.**', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
else:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
except asyncio.TimeoutError:
emb = disnake.Embed(
title='Удалить совладельца',
description=f'{interaction.author.mention}, время **вышло**!', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
@disnake.ui.button(label="Изменить название", style=ButtonStyle.gray, disabled=True, row=2)
async def bu1222zx(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
channel = interaction.guild.get_channel(int(self.find['channel']))
num1 = self.find
self.l_room = clans
emb = disnake.Embed(
title='Изменить нзвание клана',
description=f'{interaction.author.mention}, **введите** новое название.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
msg = await interaction.response.edit_message(embed=emb, view=None)
try:
res = await self.bot.wait_for("message", check=lambda i: i.author == interaction.author, timeout=60)
await res.delete()
name = res.content
await channel.edit(name=f'{name}')
self.l_room.update_one({"room_name": num1['room_name']}, {
"$set": {"room_name": name}})
emb5 = disnake.Embed(
title='Изменить нзвание клана',
description=f'{interaction.author.mention}, **Вы** успешно **изменили** название клана на: **{name}**.', color=0x2f3136
)
emb5.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb5, view=clan_button_back(self.find, self.bot, self.member))
except asyncio.TimeoutError:
emb = disnake.Embed(
title='Изменить нзвание клана',
description=f'{interaction.author.mention}, время **вышло**!', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
@disnake.ui.button(label="Изменить цвет", style=ButtonStyle.gray, disabled=True, row=2)
async def bu1222zxzxhj(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
channel = interaction.guild.get_channel(int(self.find['channel']))
num1 = self.find
self.l_room = clans
emb = disnake.Embed(
title='Изменить цвет',
description=f'{interaction.author.mention}, **введите** новый цвет.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
msg = await interaction.response.edit_message(embed=emb, view=None)
try:
res = await self.bot.wait_for("message", check=lambda i: i.author == interaction.author, timeout=60)
await res.delete()
col = res.content
colors = col\
.replace("#", "")
role = interaction.guild.get_role(num1['role'])
color = int(f"{colors}", 16)
await role.edit(color=disnake.Color(color))
emb = disnake.Embed(
title='Изменить цвет',
description=f'{interaction.author.mention}, **Вы** успешно **изменили** цвет **клана** на **{col}**.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await msg.edit(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
except asyncio.TimeoutError:
emb = disnake.Embed(
title='Смена Цвета Роли',
description=f'{interaction.author.mention}, время **вышло**!', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await msg.edit(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
@disnake.ui.button(label="Закрыть", style=ButtonStyle.red, row=3)
async def bu1222zxzx(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
await interaction.delete_original_message()
class clan_button(disnake.ui.View):
def __init__(self, find, bot, member: disnake.Member):
self.find = find
self.bot = bot
self.member = member
super().__init__(timeout=None)
@disnake.ui.button(label="Пригласить в клан", style=ButtonStyle.gray, row=1)
async def bu1(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
role = interaction.guild.get_role(self.find['role'])
if len(role.members) >= 30:
embed = disnake.Embed(title="Пригласить в клан", description=f"{interaction.author.mention}, **превышен** лимит **участников**.", color=0x2f3136).set_thumbnail(
url=interaction.author.display_avatar)
await interaction.response.edit_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
else:
emb = disnake.Embed(
title='Пригласить участника в клан',
description=f'{interaction.author.mention}, **упомяните** пользователя.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.response.edit_message(embed=emb, view=None)
try:
res = await self.bot.wait_for("message", check=lambda i: i.author == interaction.author, timeout=60)
await res.delete()
id_mem = res.content \
.replace("<", "") \
.replace("@", "") \
.replace("!", "") \
.replace(">", "")
try:
member = await interaction.guild.fetch_member(int(id_mem))
except:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
raise
if member.bot:
embed = disnake.Embed(title="Пригласить участника в клан",
description=f"{interaction.author.mention}, Вы **не можете** провести **данную** операцию с **ботом...** ", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
if member == interaction.author:
embed = disnake.Embed(title="Пригласить участника в клан",
description=f"{interaction.author.mention}, Вы **не можете** пригласить **сами у себя**.", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
channel = interaction.guild.get_channel(
int(self.find['channel']))
if member:
role = interaction.guild.get_role(self.find['role'])
if role in member.roles:
emb = disnake.Embed(
title='Пригласить участника в клан',
description=f'{interaction.author.mention}, у {member.mention} **уже есть** роль клана <#{self.find["channel"]}>', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
else:
post = {
"id": member.id,
"online": 0,
"pair": "Отсутствует",
"clan": "Отсутствует",
"balance": 0,
"rooms": [],
"clan_room_id": 0,
"message": 0,
"status": "Отсутствует"
}
if coll.count_documents({"id": member.id}) == 0:
coll.insert_one(post)
if int(m.find_one({"id": member.id})['clan_room_id']) != 0:
emb = disnake.Embed(
title='Пригласить участника в клан',
description=f'{interaction.author.mention}, у {member.mention} **уже есть** роль клана <#{self.find["channel"]}>', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
else:
emb = disnake.Embed(
title='Пригласить участника в клан',
description=f'{interaction.author.mention}, {member.mention} **был** успешно **приглашен** в клан <#{self.find["channel"]}>', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
msg = await interaction.edit_original_message(embed=emb)
#print(self.find["channel"])
bud = View(timeout=100)
accept = Button(label='Да')
cancel = Button(label='Нет')
bud.add_item(accept)
bud.add_item(cancel)
emb1 = disnake.Embed(
title=f'Приглашение в клан',
description=f'{interaction.user.mention}, вы уверены что хотите пригласить {member.mention} в клан?', color=0x2f3136)
emb1.set_thumbnail(
url=interaction.user.display_avatar)
emb1.set_footer(
text=f'Если у пользователя закрыто лс, Вы получите извещение об этом в лс.')
await msg.edit(embed=emb1, view=bud)
async def accept_button_(push):
if push.author != interaction.author:
pass
return
emb1 = disnake.Embed(
title = "Приглашение в клан",
description = f"{interaction.user.mention}, ваше приглашение успешно было отправлено пользователю {member.mention}",
color=0x2f3136
)
emb1.set_thumbnail(url=interaction.user.display_avatar)
await msg.edit(embed=emb1, view=None)
# ======
buds = View(timeout=300)
accepts = Button(label='Да')
cancels = Button(label='Нет')
buds.add_item(accepts)
buds.add_item(cancels)
# =======
emb = disnake.Embed(
title='Приглашение в клан',
description=f'{member.mention}, пользователь {interaction.user.mention} отправил **вам** приглашение вступить в клан!', color=0x2f3136)
emb.set_thumbnail(url=member.avatar)
try:
msg_mem = await member.send(embed=emb, view=buds)
except:
await interaction.user.send(f'**Не удалось** отправить ваше предложение о вступление в клан пользователю {member.mention} в лс! Возможно у него оно закрыто!')
# =====
async def accepts_button_(push):
if push.author != member:
pass
return
clanch = self.bot.get_channel(self.find["channel"])
#print(clanch.name)
coll.update_one({"id": member.id}, {"$set": {"clan": clanch.name, "clan_room_id": channel.id}})
await member.add_roles(role)
await channel.set_permissions(member, connect=True, view_channel=True)
emb = disnake.Embed(
title='Приглашение в клан',
description=f'{member.mention}, Вы успешно **вступили** в клан, в который вас пригласил(-а) {interaction.user.mention}!', color=0x2f3136)
emb.set_thumbnail(url=member.avatar)
emb1 = disnake.Embed(
title='Приглашение в клан',
description=f'{interaction.user.mention}, пользователь {member.mention} вступил в ваш клан', color=0x2f3136)
emb1.set_thumbnail(url=member.avatar)
await msg_mem.edit(embed=emb, view=None)
await msg.edit(embed=emb1, view=None)
# =====
accepts.callback = accepts_button_
async def cancels_button_(push):
if push.author != member:
pass
return
emb = disnake.Embed(
title='Приглашение в клан',
description=f'{member.mention}, Вы **отказались** от предложения {interaction.user.mention} вступить в клан!', color=0x2f3136)
emb.set_thumbnail(url=member.avatar)
await msg_mem.edit(embed=emb, view=None)
# ====
emb = disnake.Embed(
title='Приглашение в клан',
description=f'{interaction.user.mention}, пользователь {member.mention} **отказал** вам в приглашении в клан!', color=0x2f3136)
emb.set_thumbnail(url=member.avatar)
await interaction.user.send(embed=emb)
await msg.edit(embed=emb, view=None)
cancels.callback = cancels_button_
async def cancel_button_(push):
if push.author != interaction.author:
pass
return
emb = disnake.Embed(
title='Приглашение в клан',
description=f'{interaction.user.mention}, **Вы** отменили приглашение пользователю {member.mention}!', color=0x2f3136)
emb.set_thumbnail(
url=interaction.user.display_avatar)
await msg.edit(embed=emb, view=None)
cancel.callback = cancel_button_
accept.callback = accept_button_
else:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
except asyncio.TimeoutError:
emb = disnake.Embed(
title='Пригласить участника в клан',
description=f'{interaction.author.mention}, время **вышло**!', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
msg = await interaction.response.edit_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
@disnake.ui.button(label="Исключить из клана", style=ButtonStyle.gray, row=1)
async def bu12(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
channel = interaction.guild.get_channel(int(self.find['channel']))
emb = disnake.Embed(
title='Исключить из клана',
description=f'{interaction.author.mention}, **упомяните** пользователя.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
msg = await interaction.response.edit_message(embed=emb, view=None)
try:
res = await self.bot.wait_for("message", check=lambda i: i.author == interaction.author, timeout=60)
await res.delete()
id_mem = res.content \
.replace("<", "") \
.replace("@", "") \
.replace("!", "") \
.replace(">", "")
try:
member = await interaction.guild.fetch_member(int(id_mem))
except:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
raise
if member:
if member.bot:
embed = disnake.Embed(
title="Исключить из клана", description=f"{interaction.author.mention}, Вы **не можете** провести **данную** операцию с **ботом...** ", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
if member == interaction.author:
embed = disnake.Embed(
title="Исключить из клана", description=f"{interaction.author.mention}, Вы **не можете** исключить **сами себя**.", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
role = interaction.guild.get_role(self.find['role'])
if role in member.roles:
emb = disnake.Embed(
title='Исключить из клана',
description=f'{interaction.author.mention}, {member.mention} **Был** успешно **исключен** из клана <#{channel.id}>', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await interaction.edit_original_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
await channel.set_permissions(member, connect=False, view_channel=False)
coll.update_one({"id": member.id}, {
"$set": {"clan": "Отсутствует", "clan_room_id": 0}})
for i in clans.find({"manage_id": member.id, "guild_id": interaction.guild.id, "prava": 1}):
clans.delete_one(i)
try:
await member.remove_roles(role)
except:
pass
else:
embed = disnake.Embed(
title="Исключить из клана", description=f"{interaction.author.mention}, **Не** состоит в **вашем** клане. ", color=0x2f3136)
embed.set_thumbnail(url=interaction.author.display_avatar)
return await interaction.edit_original_message(embed=embed, view=clan_button_back(self.find, self.bot, self.member))
else:
emb = disnake.Embed(
title='Ошибка!',
description=f'{interaction.author.mention}, я **не могу** найти данного пользователя! Попробуйте ещё раз.', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await msg.edit(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
except asyncio.TimeoutError:
emb = disnake.Embed(
title='Исключить из клана',
description=f'{interaction.author.mention}, время **вышло**!', color=0x2f3136
)
emb.set_thumbnail(url=interaction.author.display_avatar)
await msg.edit(embed=emb, view=clan_button_back(self.find, self.bot, self.member))
@disnake.ui.button(label="Добавить совладельца", style=ButtonStyle.gray, row=1)
async def bu122(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
if interaction.author != self.member:
pass
return
channel = interaction.guild.get_channel(int(self.find['channel']))
okss = []
for i in clans.find({"channel": channel.id, "prava": 1}):
okss.append(i)
if len(okss) == 1:
emb = disnake.Embed(
title='Добавить совладельца',
description=f'{interaction.author.mention}, **Вы** превысили **лимит** совладельцов.', color=0x2f3136
)
emb.set_thumbnail(
url=interaction.author.display_avatar)
await interaction.response.edit_message(embed=emb, view=clan_button_back(self.find, self.bot, self.member))