This repository was archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
1206 lines (1059 loc) · 30.3 KB
/
main.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
# PackedBerry
print("System Started")
import os
import discord
import server
import system
import storage
import nacl
import requests
import fun
import sub1
import twm
import pb_cmd
import threading
import pytube
import random
import better_profanity
import sys
import youtubesearchpython
def search_video(query:str):
videosSearch = youtubesearchpython.VideosSearch(str(query), limit = 1)
return videosSearch.result()
def get_video_data(query:dict):
r = {}
d = search_video(query)
for _ in d:
l = d[_]
for e in l:
f = e
for i in f:
if i in ['link', 'title', 'duration', 'viewCoutn']:
r.update({i : f[i]})
return r
def text_filter(text:str):
pf = better_profanity.profanity
words = text.split(' ')
if pf.contains_profanity(text):
filtered = pf.censor(text, '#')
_ = filtered.split(' ')
filtered_words = []
for i in range(len(_)):
word = _[i]
if _[i] == words[i]:
pass
else:
word = words[i]
word = '||' + str(word) + '||'
filtered_words.append(word)
filtered_message = '(*This message has some bad words hidden by spoilers.*)\n\n' + ' '.join(filtered_words)
else:
filtered_message = text
return [pf.contains_profanity(text), filtered_message]
def get_title(url: str):
html = requests.get(url).text
title_separator = html.split("<title>")
title = title_separator[1].split("</title>")[0]
return title
def advertisement():
adf = open('scam/scam', 'r')
adl = adf.read().split('\n')
ad = adl[random.randint(0, len(adl) - 1)]
ad = str(ad)
adf.close()
return ad
def show_ad(id):
f = open('no-ads/na', 'r')
d = str(f.read())
f.close()
l = d.split('\n')
if str(id) in l:
return False
else:
return True
async def reply(stop, ad, ctx, msg):
message = msg
embed = None
m = None
try:
if "694131271776862259" in ctx.content:
embed = discord.Embed(
color = 0x2f3136,
title = "**` X T O P Y ! `**",
description = "**` F A W K ! `**"
)
user = await client.fetch_user(694131271776862259)
image = user.avatar_url
embed.set_image(url=image)
m = await ctx.channel.send(embed = embed)
if stop:
return m, embed
except Exception as e:
print(e)
try:
if "781701773713997824" in ctx.content:
embed = discord.Embed(
color = 0x2f3136,
title = "**` A D I T Y A ! `**"
)
user = await client.fetch_user(781701773713997824)
image = user.avatar_url
embed.set_image(url=image)
m = await ctx.channel.send(embed = embed)
if stop:
return m, embed
except Exception as e:
print(e)
try:
if len(msg) > 1000:
f = open("temp/message.md", 'w')
f.write(msg)
f.close()
file = discord.File("temp/message.md")
embed = discord.Embed(
color = 0xcbb48b,
title = "PackedBerry!",
description = "PackedBerry is more than a simple Discord bot."
)
embed.set_thumbnail(url="https://github.com/Attachment-Studios/PackedBerry/blob/master/PackedBerry.png?raw=true")
embed.add_field(
name = str(pb_cmd.cmd_key(ctx.content.lower())),
value = "All Content In The Attachment."
)
m = await ctx.channel.send(embed = embed, file = file)
return m, embed
except Exception as e:
print(e)
try:
if ad == False:
if not(pb_cmd.emb_check(ctx.content.lower())):
m = await ctx.channel.send(message)
else:
embed = discord.Embed(
color = 0xcbb48b,
title = "PackedBerry!",
description = "PackedBerry is more than a simple Discord bot."
)
embed.set_thumbnail(url="https://github.com/Attachment-Studios/PackedBerry/blob/master/PackedBerry.png?raw=true")
embed.add_field(
name = str(pb_cmd.cmd_key(ctx.content.lower())),
value = message
)
m = await ctx.channel.send(embed = embed)
if show_ad(ctx.author.id):
if random.randint(0, 7) == 1:
em = discord.Embed(
color = 0xcbb48b,
title = "PackedBerry!",
description = "PackedBerry is more than a simple Discord bot."
)
em.set_thumbnail(url="https://github.com/Attachment-Studios/PackedBerry/blob/master/PackedBerry.png?raw=true")
em.set_image(url="https://github.com/Attachment-Studios/PackedBerry/blob/master/Social.png?raw=true")
em.add_field(
name = str('Like PackedBerry?'),
value = 'Vote For PackedBerry On DiscordBotList.com - https://discord.ly/packedberry'
)
await ctx.channel.send(embed = em)
if random.randint(0, 7) < 3:
_ad = advertisement()
emb = discord.Embed(
color = 0xcbb48b,
title = "PackedBerry!",
description = "PackedBerry is more than a simple Discord bot."
)
emb.set_thumbnail(url="https://github.com/Attachment-Studios/PackedBerry/blob/master/PackedBerry.png?raw=true")
emb.add_field(
name = str('Advertisement'),
value = _ad
)
await ctx.channel.send(embed = emb)
print(f"\033[38;2;0;255;0m\033[1m\033[3mReply\033[0m: {ctx.author}: \033[38;2;0;255;255m\033[1m\033[3m{pb_cmd.cmd_key(ctx.content.lower())}\033[0m")
else:
_ad = advertisement()
emb = discord.Embed(
color = 0xcbb48b,
title = "PackedBerry!",
description = "PackedBerry is more than a simple Discord bot."
)
emb.set_thumbnail(url="https://github.com/Attachment-Studios/PackedBerry/blob/master/PackedBerry.png?raw=true")
emb.add_field(
name = str('Advertisement'),
value = _ad
)
await ctx.channel.send(embed = emb)
except Exception as e:
print(e)
return m, embed
ls = [
0, # xp
1, # level
50, # goal
0, # author id
"levels/",
"f"
]
async def level_system(msg):
ls[3] = str(msg.author.id)
if os.path.isfile(str(f"{ls[4]} {ls[3]}")):
f = open(str(f"{ls[4]} {ls[3]}"), 'r')
d = f.read()
f.close()
ds = d.split("\n")
ls[0] = int(ds[0])
ls[1] = int(ds[1])
ls[2] = int(ds[2])
ls[0] += 1
if ls[0] >= ls[2]:
ls[2] *= 2
ls[1] += 1
await reply(False, False, msg, f"<@{ls[3]}> You got promoted to level {ls[1]}.")
ls[5] = "f"
th = threading.Thread(target=save_level)
th.start()
th.join()
def save_level():
if True:
if ls[5] == "f":
# print("System: Saving levels.")
f = open(str(f"{ls[4]} {ls[3]}"), 'w')
f.write(f"{ls[0]}\n{ls[1]}\n{ls[2]}")
f.close()
ls[5] == "t"
# print("System: Saved levels.")
print("Modules Imported")
save_servers_file = open('web/servers.pbsf', 'w')
save_servers_file.write('')
save_servers_file.close()
print("Cleared Active Servers Data")
data = [
# reference names
[
# default reference names
[
"packedberry",
"pb",
"packedberry!",
"pb!",
"packedberry?",
"pb?"
],
# all reference names
[
"packedberry",
"pb",
"packedberry!",
"pb!",
"packedberry?",
"pb?"
]
],
# mute list
[
# user
[],
# server
[]
]
]
prevent = [
#channels
[],
# authors
[]
]
youtube = [
# channel
[],
# call name
[]
]
music = [
# users
[],
# list
[]
]
qvibe = [
[]
]
mutelist = [
# user
[],
# server
[]
]
server_links = [
# server name
[],
# server link
[]
]
def save_data():
if True:
# print("Save System: Saving data.")
storage.savelist(data, 'storage/data.pbsf')
storage.savelist(prevent, 'storage/prevent.pbsf')
storage.savelist(youtube, 'storage/yt.pbsf')
storage.savelist(music, 'storage/music.pbsf')
storage.savelist(qvibe, 'storage/qvibe.pbsf')
storage.savelist(mutelist, 'storage/mute.pbsf')
storage.savelist(server_links, 'storage/serverslinks.pbsf')
# print("Save System: Saved data.")
if os.path.isfile('storage/data.pbsf'):
data = storage.getlist('storage/data.pbsf')
prevent = storage.getlist('storage/prevent.pbsf')
youtube = storage.getlist('storage/yt.pbsf')
music = storage.getlist('storage/music.pbsf')
qvibe = storage.getlist('storage/qvibe.pbsf')
mutelist = storage.getlist('storage/mute.pbsf')
server_links = storage.getlist('storage/serverslinks.pbsf')
def save():
thread = threading.Thread(target=save_data)
thread.start()
thread.join()
print("Setup Completed")
save()
async def reaction_roles(ct, rl, u, msg, g):
try:
guild = await client.fetch_guild(g)
roles = await guild.fetch_roles()
role = None
for r in roles:
if str(r.id) == str(rl):
role = r
if ct == "add":
try:
await u.add_roles(role)
except Exception as e:
print('Failed to assign user the role.')
print(e)
else:
try:
await u.remove_roles(role)
except Exception as e:
print('Failed to assign user the role.')
print(e)
except:
pass
# await m.edit('Sorry. This role has expired.')
# await m.clear_reactions()
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_member_join(member):
guild = member.guild
if os.path.isfile('welcome/' + str(guild.id)):
f = open('welcome/' + str(guild.id), 'r')
data = str(f.read())
f.close()
d = data.split('\n')
c = str(d[0])
m = str(d[1]).replace('<user>', f'{member.mention}').replace('<server>', f'{member.guild.name}')
r = str(d[2])
if c == "":
pass
else:
embed = discord.Embed(
title = 'Welcome!',
color = 0xcbb48b,
description = str(m)
)
embed.set_image(url=member.avatar_url)
await guild.get_channel(int(c)).send(embed=embed)
if r == "":
pass
else:
role = guild.get_role(int(r))
await member.add_roles(role)
else:
pass
@client.event
async def on_raw_reaction_add(payload):
p = payload
m = str(p.message_id)
s = str(p.guild_id)
u = p.member
if u == client.user:
return
if os.path.isfile('rerole/' + s):
f = open('rerole/' + s, 'r')
fd = f.read()
f.close()
dl = fd.split('\n')
for d in dl:
_d = d.split(',')
if m == _d[0]:
await reaction_roles('add', _d[1], u, m, s)
break
else:
pass
@client.event
async def on_raw_reaction_remove(payload):
p = payload
m = str(p.message_id)
s = str(p.guild_id)
uid = p.user_id
g = await client.fetch_guild(int(s))
u = await g.fetch_member(uid)
if u == client.user:
return
if os.path.isfile('rerole/' + s):
f = open('rerole/' + s, 'r')
fd = f.read()
f.close()
dl = fd.split('\n')
for d in dl:
_d = d.split(',')
if m == _d[0]:
await reaction_roles('rem', _d[1], u, m, s)
break
else:
pass
async def packedberry_setup(guild:discord.Guild):
cat = await guild.create_category(name='PackedBerry Corner')
cnl = await guild.create_text_channel(name='PackedBerry Chat', category=cat)
try:
os.mkdir(f'pb-internals/{guild.id}')
except:
pass
f = open(f'pb-internals/{guild.id}/ac', 'w')
f.write(str(cnl.id))
f.close()
await cnl.send('Latest PackedBerry setup has been completed.')
await cnl.send('In case there is another "PackedBerry Corner" please delete it to avoid confusions.')
await cnl.send('Please note this setup is automatic and if PackedBerry is added first time to this server then this will be there. Deleting this category is manual.')
return cnl
@client.event
async def on_ready():
await logberry(f'{client.user} has restarted.')
async def logberry(text:str):
guild = client.get_guild(885848184356737084)
channel = guild.get_channel(892439417669693530)
name = f'LogBerry'
avatar = client.user.avatar_url
whk = await channel.create_webhook(name="ModBerry",reason="Moderation")
await whk.send(content=text, username=name, avatar_url=avatar)
await whk.delete()
@client.event
async def on_relationship_add(relationship):
user = relationship.user
await user.send('We are friends! :D')
@client.event
async def on_relationship_remove(relationship):
user = relationship.user
await user.send("Please don't unfriend me! :(")
await user.send_friend_request()
@client.event
async def on_guild_join(guild):
f = open(f'no-spam/{guild.id}', 'w')
f.write('Spam disabled in this server.')
f.close()
c = await packedberry_setup(guild)
sc = len(server_links[0])
if guild.me.guild_permissions.administrator:
pass
else:
await c.send('Some commands might not be able to be run here. To allow them run, please give all permissions except kick and ban or just give the admin permissions.')
await logberry(f'{client.user} was added to another server. Server Count - {sc}')
def get_ping(text):
if '<@!' in text:
l = text.split(' ')
_l = []
d = {}
for _ in l:
try:
id = int(_.replace('<@!', '').replace('>', ''))
if '<@!' in str(_) and str(_) not in _l:
_l.append(str(_))
d.update(
{
_ : client.get_user(int(id)).name
}
)
except:
pass
return _l, d
else:
return False, False
async def global_chat(msg, text):
try:
if msg.author == client.user:
pass
else:
if os.path.isfile(f'cserver/{msg.guild.id}'):
f = open(f'cserver/{msg.guild.id}', 'r')
d = f.read()
f.close()
try:
if str(d) == str(msg.channel.id) or not(text == ''):
await msg.delete()
servers = os.listdir('cserver')
invite_link = await msg.channel.create_invite()
if text == '':
global_message = msg.content
else:
global_message = text
m_att = msg.attachments
for f in os.listdir('csa'):
os.remove(f'csa/{f}')
files = []
for f in m_att:
fn = f'csa/{f.filename}'
await f.save(fn)
files.append(fn)
ping_list, ping_dict = get_ping(global_message)
ping_text = ''
if not(ping_list == False):
ping_text = ', '.join(ping_list)
if ping_text == '':
pass
else:
for k in ping_dict:
global_message = global_message.replace(k, ping_dict[k])
pfc = text_filter(global_message)
if pfc[0]:
global_message = pfc[1]
for sid in servers:
try:
guild = client.get_guild(int(sid))
f = open(f'cserver/{sid}', 'r')
cid = f.read()
f.close()
if guild == None:
pass
else:
channel = guild.get_channel(int(cid))
if channel == None:
pass
else:
temp = ''
if len(global_message) > 252:
i = 0
while len(temp) < 253:
temp += str(global_message[i])
i += 1
temp += '...'
if len(global_message) > 252:
emb = discord.Embed(
title=temp,
description=f"Get [PackedBerry](https://PackedBerry.DBot.CC) in your server and type `pb cross-server` to access cross-server chat in your server as well.",
color=0x2f3136
)
emb.add_field(
name="Alert",
inline=False,
value='Message limit is 250 characters.'
)
else:
emb = discord.Embed(
title=str(global_message),
description=f"Get [PackedBerry](https://PackedBerry.DBot.CC) in your server and type `pb cross-server` to access cross-server chat in your server as well.",
color=0x2f3136
)
if text == '':
pass
emb.add_field(
name="Message Details",
value=f"""Author: @{msg.author}\nPing Code: \\<@!{msg.author.id}>\nFrom: [{msg.guild}/#{msg.channel}]({invite_link})"""
)
if text == '':
emb.set_thumbnail(url=msg.author.avatar_url)
else:
emb.set_thumbnail(url=msg.guild.icon_url)
if ping_text == "":
pass
else:
await channel.send(ping_text)
await channel.send(embed=emb)
for f in files:
file = discord.File(f)
await channel.send(file=file)
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print(exc_type, fname, exc_tb.tb_lineno)
print(e)
print(f"\033[38;2;255;255;0m\033[1m\033[3mGlobal\033[0m: {msg.author}")
return
else:
return "CONTINUE"
except Exception as e:
print(e)
return "CONTINUE"
except Exception as e:
print(e)
return "CONTINUE"
return "CONTINUE"
@client.event
async def on_message(ctx):
msg = ctx
if (msg.channel.type == discord.ChannelType.private):
if msg.author == client.user:
return
dms = twm.twm(client, msg, data[0][1])
if dms[0].replace(" ", "") == "":
if dms[2] == True:
await reply(True, True, msg, 'Ad Delivered.')
else:
return
for _ in range(int(dms[1])):
await reply(False, False, msg, dms[0])
return
if msg.author.bot == True:
if msg.author.id == 888277005261492225:
pass
else:
return
value = await global_chat(msg, '')
if value == None:
return
try:
if msg.author.bot == True:
if msg.author.id == 888277005261492225:
pass
else:
return
else:
m = msg.content
pfc = text_filter(m)
if pfc[0] == True:
try:
name = f'{msg.author}'
avatar = msg.author.avatar_url
whk = await msg.channel.create_webhook(name="ModBerry",reason="Moderation")
await whk.send(content=f'{pfc[1]}', username=name, avatar_url=avatar)
await whk.delete()
except Exception as e:
print(e)
await ctx.channel.send(f'{pfc[1]}\n__***~{msg.author.mention}***__')
await ctx.delete()
except Exception as e:
print(e)
if msg.guild.me.guild_permissions.administrator:
if os.path.isfile(f'pb-internals/{msg.guild.id}/ac'):
pass
else:
await packedberry_setup(msg.guild)
else:
try:
if os.path.isfile(f'pb-internals/{msg.guild.id}/ac'):
f = open(f'pb-internals/{msg.guild.id}/ac', 'r')
try:
cid = int(f.read())
c = msg.guild.get_channel(cid)
if msg.content.lower().split(' ')[0] in data[0][1]:
await c.send('Some commands might not be able to be run here. To allow them run, please give all permissions except kick and ban or just give the admin permissions.')
else:
pass
except:
pass
f.close()
else:
c = await packedberry_setup(msg.guild)
await c.send('Some commands might not be able to be run here. To allow them run, please give all permissions except kick and ban or just give the admin permissions.')
except:
pass
for _ in range(1):
if msg.author == client.user:
break
print(f"\033[38;2;255;255;0m\033[1m\033[3mMessage\033[0m: {msg.author}")
await level_system(msg)
if str(msg.guild) not in server_links[0]:
try:
invite = await msg.channel.create_invite(unique=False)
server_links[0].append(str(msg.guild))
server_links[1].append(str(invite))
except:
pass
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Discord Server - " + str(msg.guild)))
if msg.content.lower() == 'pb -su -unlock':
i = prevent[0].index(str(msg.channel.id))
prevent[0][i] = ''
prevent[1][i] = ''
await msg.delete()
await reply(False, False, msg, '--/-- Unlocked --/--')
break
if msg.content.lower() == 'pb unlock':
i = prevent[0].index(str(msg.channel.id))
if str(msg.author.id) == str(prevent[1][i]):
prevent[0][i] = ''
prevent[1][i] = ''
await reply(False, False, msg, '--/-- Unlocked --/--')
await msg.delete()
break
if system.mute(msg.author.id, mutelist[0], msg.guild.id, mutelist[1]):
await msg.delete()
break
if str(msg.channel.id) in prevent[0]:
await msg.delete()
break
cch = pb_cmd.cmd_check(msg.content.lower(), data[0][1])
if cch == []:
break
elif cch == None:
pass
elif cch == "pingberry":
await reply(True, False, msg, '** **')
elif cch == True:
pass
elif cch == False:
out = "If you think that is a command.\n```diff\n-> Your thought is arguable. <-\n```"
await reply(False, False, msg, str(out))
break
try:
m = msg.content.lower().split(' ')
cmd = m[1]
if m[0] in data[0][1]:
if cmd == "pfp":
try:
user = await client.fetch_user(int(str(m[2]).replace('@', '').replace('<', '').replace('>', '').replace('!', '')))
except:
user = msg.author
embed = discord.Embed(
color = 0x2f3136,
title = user.name
)
embed.set_image(url=user.avatar_url)
await msg.channel.send(embed=embed)
break
except:
pass
try:
if False:
change = True
for _ in (client.voice_clients):
if _.is_playing():
if msg.guild.id == _.guild.id:
change = False
if change:
await msg.guild.me.edit(nick="PackedBerry")
except:
pass
if msg.content.lower() == 'pb -su -unmute -id --self':
ids = []
for elem in range(len(mutelist[0])):
if str(msg.author.id) == str(mutelist[0][elem]):
ids.append(elem)
for i in ids:
mutelist[0].remove(mutelist[0][i])
mutelist[1].remove(mutelist[1][i])
await msg.delete()
try:
servers_file = open('web/servers.pbsf', 'r')
all_servers_temp = servers_file.read()
servers_file.close()
invite = str(server_links[1][server_links[0].index(str(msg.guild))])
all_servers_temp = all_servers_temp.replace('<h3 onclick="window.open(\'' + str(invite) + '\');">' + str(msg.guild) + '</h3>', '')
all_servers_temp = '<h3 onclick="window.open(\'' + str(invite) + '\');">' + str(msg.guild) + '</h3>' + str(all_servers_temp)
save_servers_file = open('web/servers.pbsf', 'w')
save_servers_file.write(all_servers_temp)
save_servers_file.close()
except:
pass
if os.getenv("_UNMUTE") in msg.content.lower():
try:
data[1].remove(int(msg.content.lower().replace(os.getenv("_UNMUTE"), "")))
await msg.delete()
except:
pass
try:
if msg.content.lower().split(" ")[0] in data[0][1]:
if msg.content.lower().split(" ")[1] == "delete":
if msg.author.guild_permissions.administrator:
try:
await msg.channel.purge(limit=int(msg.content.lower().split(" ")[2]))
except Exception as e:
print(e)
try:
if msg.content.lower().split(" ")[2] == "channel":
await msg.channel.purge(limit=10000)
except:
await msg.channel.purge(limit=1)
else:
await reply(False, False, msg, 'Admin permission needed.')
if msg.content.lower().split(" ")[1] == "burn":
if msg.author.guild_permissions.administrator:
await msg.channel.purge(limit=10000)
else:
await reply(False, False, msg, 'Admin post required.')
if msg.content.lower().split(" ")[1] == "prevent":
if msg.author.guild_permissions.administrator:
await msg.delete()
await reply(False, False, msg, '--X-- Locked --X--')
prevent[0].append(str(msg.channel.id))
prevent[1].append(str(msg.author.id))
else:
await reply(False, False, msg, 'Admin Post Required.')
except:
pass
try:
if msg.content.lower().split(' ')[0] in data[0][1]:
m = msg.content.split(' ')
out = ""
m_langs = []
try:
if m[1].lower() == 'yt':
try:
if m[2].lower() == 'add':
try:
if m[3] in youtube[1]:
out = "This url is occupied for " + youtube[0][youtube[1].index(m[3])]
else:
if 'youtu' in m[3].lower():
channel_name = msg.content.replace(m[0] + ' ' + m[1] + ' ' + m[2] + ' ', '')
out = channel_name
else:
out = "URL doesn't correspond to youtube."
except:
out = "Please give a valid url."
except:
if len(youtube[0]) > 0:
out = '```yml\n'
m_langs.append('yml')
for url in youtube[1]:
out = out + youtube[0][youtube[1].index(url)] + ': ' + url + '\n'
out = out + '```'
except:
pass
send_text = str(out)
if len(send_text) > 0:
if len(send_text) < 2000:
await reply(False, False, msg, send_text)
break
else:
for lang in m_langs:
send_text = send_text.replace('```' + str(lang), '')
send_text = send_text.replace('```', '')
long_message = open('message.md', 'w')
long_message_txt = open('message.txt', 'w')
long_message.write(send_text)
long_message_txt.write(send_text)
long_message.close()
long_message_txt.close()
await reply(False, False, msg, file=discord.File('message.md'))
await reply(False, False, msg, file=discord.File('message.txt'))
break
except:
pass
try:
fun_system = fun.work(msg, data[0][1], server_links)
if fun_system[0]:
m, e = await reply(False, False, msg, fun_system[1])
if fun_system[5] == True:
await m.add_reaction('✅')
await m.add_reaction('❎')
if fun_system[4] == True:
await msg.delete()
if fun_system[2] == True:
embed = discord.Embed(
color = 0xcbb48b
)
embed.add_field(
name = "PackedBerry!",
value = fun_system[3]
)
await msg.author.send(embed=embed)
await msg.delete()
except:
pass
try:
sub1data = sub1.protocol(client, msg, data[0][1])
if sub1data[0].replace(" ", "") == "":
pass
else:
do_ad = False
if sub1data[7] == True:
try:
await msg.author.send_friend_request()
except Exception as e:
print(e)
if not(sub1data[6] == False):
await global_chat(msg, sub1data[6])
if sub1data[5] == True:
await packedberry_setup(msg.guild)