-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
877 lines (748 loc) · 34 KB
/
main.py
File metadata and controls
877 lines (748 loc) · 34 KB
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
import discord
from discord.ext import commands, tasks
import os
from scheduler import scheduler
import datetime
from datetime import *
import pytz
import random
from replit import db
import requests
import time
import sys
from threading import Thread
import json
import asyncio
#Start up@
intents = discord.Intents.default()
intents.members = True
activity = discord.Game(name="$help | $cmd for commands")
bot = commands.Bot(command_prefix="$",activity=activity,status=discord.Status.online, help_command=None,intents=intents)
bot.help_command = None
bot.strip_after_prefix = True
tme = time
print(f"Repl Database keys in use : {db.keys()}")
for key in db.keys():
print(f"{key} : {db[str(key)]}")
#Bot status check
async def b_status():
global x
while True:
if bot.is_closed() == True:
print("Bot offline")
print("Rebooting")
break
else:
await asyncio.sleep(5)
await asyncio.sleep(5)
#background_task.stop()
#scheduling.stop()
#await bot.connect(reconnect = True)
## BELOW USED FOR BOT ##
def separate_str(string):
building_word = ''
word_list = []
if string != '()' and string != "":
for char in string:
if char != " " and char != "(" and char != ")" and char != ",":
building_word += char
else:
word_list.append(building_word)
building_word = ''
return word_list
### BOT'S COMMAND LIST BELOW! ###
### ALPHABETICAL ORDER PLEASE ###
#https://www.i2symbol.com/symbols/corner link to unicode characters for stuff like this: └
#see Dank Memer pls help to see more
'''
Notice: Before each command, there SHOULD be a comment detailing the command and how to use it.
For example:
#test() is for testing. Ex: $test, $ttt
@bot.command()
'''
@bot.command()
async def test(ctx):
for item in bot.users:
break
if not item.bot:
print(item.id)
await ctx.send(item.id)
await ctx.send(item)
#_9ball is for 'determining the future' (not really). Ex: $_9ball <prompt>, $9ball <prompt>, $9 <prompt>
@bot.command(aliases=['9ball', '9b'])
async def _9ball(ctx,*args): #unfortunally, async def 8ball(): returned an error
#list of predictions to (randomly) choose from
predictions = [
"Don't count on it.", 'My reply is no.',
'My sources say no.', 'Outlook not so good.', 'Very doubtful.'
]
if str(args) != '()':
msg = random.choice(predictions)
else:
msg = 'No prompt given. Try `$9ball <prompt>`'
await ctx.send(msg)
#_8ball is for 'determining the future' (not really). Ex: $_8ball <prompt>, $8ball <prompt>, $8b <prompt>
@bot.command(aliases=['8ball', '8b'])
async def _8ball(ctx,*args): #unfortunally, async def 8ball(): returned an error
#list of predictions to (randomly) choose from
predictions = [
'It is certain.', 'It is decidedly so.', 'Without a doubt.',
'Yes definitely.', 'You may rely on it.', 'As I see it, yes.',
'Most likely.', 'Outlook good.', 'Yes.', 'Signs point to yes.',
'Reply hazy, try again.', 'Ask again later.',
'Better not tell you now.', 'Cannot predict now.',
'Concentrate and ask again.', "Don't count on it.", 'My reply is no.',
'My sources say no.', 'Outlook not so good.', 'Very doubtful.'
]
if str(args) != '()':
msg = random.choice(predictions)
else:
msg = 'No prompt given. Try `$8ball <prompt>`'
await ctx.send(msg)
#_7ball is for 'determining the future' (not really). Ex: $_7ball <prompt>, $7ball <prompt>, $7b ( Jeopardised version of 8 ball) <prompt>
@bot.command(aliases=['7ball', '7b'])
async def _7ball(ctx,*args): #unfortunally, async def 7ball(): returned an error
#list of predictions to (randomly) choose from
predictions = [
'It is certain.', 'It is decidedly so.', 'Without a doubt.',
'Yes definitely.', 'You may rely on it.', 'As I see it, yes.',
'Most likely.', 'Outlook good.', 'Yes.', 'Signs point to yes.',
]
if str(args) != '()':
msg = random.choice(predictions)
else:
msg = 'No prompt given. Try `$7ball <prompt>`'
await ctx.send(msg)
#avatar is to show your's, or someone else's avatar. Ex: $avatar, $avatar @mention, $avatar {id}
@bot.command(aliases=['av'])
async def avatar(ctx, *, avamember: discord.Member = None):
if avamember == None:
avamember = await bot.fetch_user(ctx.author.id)
elif avamember is int:
avamember = await bot.fetch_user(avamember)
userAvatarUrl = avamember.avatar_url
embd = discord.Embed(title="Avatar")
embd.set_image(url=userAvatarUrl)
await ctx.send(embed=embd)
#calc() is for calculator
@bot.command()
async def calc(ctx, *args):
equation = ''
for item in args:
equation += str(item)
try:
await ctx.send(eval(equation))
except:
pass
#time() is for getting a random time. It is a by product of the scheduing function
@bot.command(aliases=['time'])
async def clock(ctx):
file = scheduler()
embed = discord.Embed(title="Time", color=0x808080)
embed.set_footer(text="Written with python")
file = discord.File("assets/temp/temp.png", filename="temp.png")
embed.set_image(url="attachment://temp.png")
await ctx.reply(file=file, embed=embed, mention_author=False)
import os
os.remove(f'assets/temp/temp.png')
#cmd() is for getting a list of cmds. For now it is a list, aiming to build a list like Dank Memer
@bot.command(aliases=['command', 'cmds', 'commands', 'com'])
async def cmd(ctx, *args):
if str(args) != '()':
pass #for looking up a specific cmd
else:
await ctx.send('`$cmd <optional: specific command>`')
cmds = ''
#For each pair in the dictionary of commands
for pair in bot.all_commands.items():
cmds += f"`{pair[0]}`, "
#Create an embed with all the Commands
embd = discord.Embed(title="COMMANDS", description=str(cmds))
await ctx.send(embed=embd)
#credits is to show credits. Ex: $credits
@bot.command(aliases=['credit', 'contributors', 'developers', 'dev', 'devs'])
async def credits(ctx):
embd = discord.Embed(title="CREDITS", color=discord.Color.teal())
embd.add_field(
name='Developers',
value=
"**Isaac**, your official macho man.\n**James**, wielder of the flying axe <:flyingaxe:884865624914939975>.\n**Daniel**, Hollywood alias 'Daniellus Di'Egro'\n**Christopher**, Eopic kid."
)
embd.add_field(
name='Contributors',
value=
"Input your bot ideas in <#839143757748109334> to become a contributor!",
inline=False)
await ctx.send(embed=embd)
#help() is for asking for help. Ex: $help
@bot.command(aliases=['Help', 'bothelp'])
async def help(ctx):
embd = discord.Embed(
title='Homelands Bot Help',
description=
"**Hi! Welcome to the Homelands Bot Help Manual**\nI am proud to be part of the Homeland's community!I can currently do a few things, altough you can check my current commands by typing `$help`. Homelands bot aims to provide support, such as reminders, fun games, homework support, and more!\n Have fun and **GO HOMELANDS**!",
color=discord.Color.blue())
embd.set_footer(text="Written with Python.")
embd.set_image(
url=
'https://cdn.discordapp.com/attachments/842823949037076520/879383578742517780/unknown.png'
)
embd.add_field(name='Prefix', value='`$`', inline=False)
embd.add_field(name='Commands',
value='`$cmd` for more info.',
inline=False)
embd.add_field(
name='Peel Link',
value=
'[www.peelschools.org](https://www.peelschools.org/Pages/default.aspx)',
inline=True)
embd.add_field(
name='School Holidays',
value=
'[Holidays](https://www.peelschools.org/calendar/Documents/School%20Year%20Calendar%202021-2022%20Regular%20Elementary%20and%20Secondary%20chart.pdf)',
inline=True)
await ctx.send(embed=embd)
#hi() is for saying hello. Ex: $hi, $hello
@bot.command(aliases=[
'hello', 'hi!', 'hello!', 'hi there', 'Hi there', 'Hi there!', 'Howdy!',
'howdy!', 'Hello', 'Hello!', 'Hi!', 'Hi'
])
async def hi(ctx):
responses = ['Hello', 'Hi!', 'Hello!', 'Hi there', 'Hi there!', 'Howdy!', 'Hello!', 'Hi', 'Greetings', 'Salutations', 'Welcome',"Bonjour","Hola","Ciao","Olá","G’day","Privet","你好"]
await ctx.reply(random.choice(responses), mention_author=False)
#infect() is the infection game and whoever is infect will use this command to infect another individual
@bot.command()
async def infect(ctx, *args):
if db["infected"] == int(ctx.message.author.id):
try:
finlist = int(args[0])
except:
userid =list(args[0])
x = 0
finlist = ''
for item in userid:
if x < 4 or x == len(userid) -1:
pass
else:
finlist += str(item)
finlist = int(finlist)
db["infected"] =int(finlist)
channel = bot.get_channel(919281999427043369)
infectedembed = discord.Embed(title = "Infection", description = f"The infection has been passed on to '<@!{int(finlist)}>")
await channel.send(embed=infectedembed)
user = await bot.fetch_user(int(finlist))
embd = discord.Embed(title = "You have been infected!",description = "Pass on the infection to someone else by typing `$infect {user id}` in an channel in the ELC server. Doing so will also remove the infection from you.\n\nIf you don't know how to get user id:\n\n1.Go to user settings\n2.Click on Advanced\n3.Turn on developer mode\n4.Press the Esc key\n5.Right click a user in the member list on the side and click Copy ID")
await user.send(embed=embd)
await ctx.message.delete()
else:
await ctx.send("You are not infected!")
await ctx.message.delete()
#server() is for server information. Similar to the !server command made by carl-bot
@bot.command()
async def server(ctx, *args):
if len(args) == 0:
embed = discord.Embed(
title="Server Information",
description=
f'ELC Homelands is a server is for texting, homework help (Covering all subjects) , reminders and more. With a wide community of **{ctx.guild.member_count}** members, we wish to provide you with the best school server experience.',
color=0x808080)
embed.set_author(name="Homelands Bot",
url='https://www.peelschools.org/Pages/default.aspx',
icon_url="https://www.microcad.ca/images/pdsb.png")
embed.set_footer(
text="$server [keyword] • Use !server for a list of keywords!")
embed.add_field(
name='Main Features',
value=
"• Texting\n• Reminders\n• Homework Help\n• A welcoming community\n• Fun!\n• A well-moderated chat!"
)
embed.add_field(
name='Actions',
value=
'`boost`, `bots`, `create`, `emojis`, `events`, `features`', inline = False) #`giveaways`, `icon`, `invite`, `owner`, `members`, `rules`, `staff`',
#inline=False)
embed.set_image(
url=
r'https://res.cloudinary.com/demo/image/upload/w_350,h_100,e_colorize,co_rgb:000000,r_5/l_text:Montserrat_25:ELC%20Homelands,co_rgb:FFFFFF,g_center/one_pixel.png'
)
await ctx.reply(embed=embed, mention_author=False)
elif args[0] == 'boost':
embed = discord.Embed(title="Server Boost", color=0x808080)
embed.set_author(name="Homelands Bot",
url='https://www.peelschools.org/Pages/default.aspx',
icon_url="https://www.microcad.ca/images/pdsb.png")
embed.add_field(
name='--',
value=
f'Boost us to get even more perks! You can sleep knowing you are cool and have your own hoisted role! <:sunglasses:887516435742593075>'
)
embed.add_field(
name='Booster Only Perks',
value=
f"• You'll be the most awesomeness\n• Access to make an autoresponse or autoreact when someone pings you!",
inline=False)
embed.set_footer(
text="$server [keyword] • Use !server for a list of keywords!")
embed.set_image(
url=r'https://i.ytimg.com/vi/ZyX7U78keu0/maxresdefault.jpg')
await ctx.reply(embed=embed, mention_author=False)
elif args[0] == 'bots':
embed = discord.Embed(
title="Server Bots",
description=
"We have bots that provide useful features!\n\nHere's a list of them and what they do below:",
color=0x808080)
embed.set_author(name="Homelands Bot",
url='https://www.peelschools.org/Pages/default.aspx',
icon_url="https://www.microcad.ca/images/pdsb.png")
embed.add_field(
name='--',
value=
f'<@!235148962103951360> Mod bot\n<@!155149108183695360> Mod Bot\n<@!822488670153474098> $help for more details\n<@!487328045275938828> Fun Bot!\n<@!201503408652419073> Music\n'
)
embed.set_footer(
text="$server [keyword] • Use !server for a list of keywords!")
embed.set_image(
url=
r'https://bs-uploads.toptal.io/blackfish-uploads/blog/post/seo/og_image_file/og_image/21026/how-to-make-a-discord-bot-7c0fe302b98b05b145682344b3a4ec59.png'
)
await ctx.reply(embed=embed, mention_author=False)
elif args[0] == 'create':
embed = discord.Embed(
title="Server Bots",
description=
"We have bots that provide useful features!\n\nHere's a list of them and what they do below:",
color=0x808080)
embed.set_author(name="Homelands Bot",
url='https://www.peelschools.org/Pages/default.aspx',
icon_url="https://www.microcad.ca/images/pdsb.png")
server = bot.get_guild(839135669712060486)
format = "%a, %d %b %Y | %H:%M:%S %ZEDT"
server_creation = server.created_at.strftime(format)
embed.add_field(name='--', value=f'{server_creation}')
embed.set_footer(
text="$server [keyword] • Use !server for a list of keywords!")
embed.set_image(
url=
r'https://www.gematsu.com/wp-content/uploads/2021/05/PS-Discord_05-03-21.jpg'
)
await ctx.reply(embed=embed, mention_author=False)
elif args[0] == 'emojis':
embed = discord.Embed(title="Server Emojis",
description="Emojis here",
color=0x808080)
embed.set_author(name="Homelands Bot",
url='https://www.peelschools.org/Pages/default.aspx',
icon_url="https://www.microcad.ca/images/pdsb.png")
embed.add_field(
name='**Here is a list of our Emojis!**\n',
value=
f'<:angery:875389778550468648> - Heh\n<:babyisaac:875390321943511100> - Haha chubby\n<:carlbot:857614103232380932> - Tortle\n<:flyingaxe:884865624914939975> - James wields this... beware\n<:gasp:872176337618628648> - *Gasp*\n<:godiedieinawholehole:852669994684514334> - Cmon Aimee\n<:grumpycat:857614180852695080> - l o l\n<:imsuingyoulady:852669995188092959> - Cmon Aimee\n<:ohno:859976978551013396> - Oh no... \n<:ulittlebush:852669975218749460> - Cmon Aimee\n<:why:873303024053928076> - Why\n<:winky:888892068842319953> - One of the first custom emojis in our server!\n<:Wizardhat:909435141288501328> - You\'re a wizard, Harry!\n<:adios:897096452856250389> - Goodbye\n<:disappointed:916513763778252810> - Conan when you tell him you play Genshin\n<:doublepong:911047080007593994> - haha ping go brrr\n',
inline=False)
embed.add_field(name='.',value='<:drainedcat:911012930080886804> - No explanation needed**.**\n<:frickkk:917913815713189898> - We all know this feeling\n<:huh:914561577515102268> - *Visible confusion*\n<:invis:896410118797795381> - ...\n<:mydadznutz:909514397905465424> - Crunchy!\n<:mydadznutz2:909515229686276117> - Yum!\n<:omg:916697166146326530> - Isaac\'s pure ricjness\n<:ouch:916704152632045650> - Your face\n<:pensivecowboy:919251960190877729> - No explanation needed\n<a:ohno:914563971170852916> - Oh no...\n<:pixelsadge:919252433299996712> - We all know this feeling\n<:pong:909492236843106355> - haha ping go brrr\n<:pooprollingeyes:914634018111242313> - The emojis that Isabella hates\n<:smuggie:919251740166062100> - l o l\n<:tsktsk:914540098920546316> - tsktsk\n<:wide_daniel:895842460482285628> - Ricj man, but wider')
embed.set_footer(
text="$server [keyword] • Use !server for a list of keywords!")
embed.set_image(
url=
r'https://user-images.githubusercontent.com/3952718/89732919-2ddf3e00-da52-11ea-9ea5-59df51a6c25e.png'
)
await ctx.reply(embed=embed, mention_author=False)
elif args[0] == 'events':
embed = discord.Embed(
title="Server Events",
description="All events that we host will be here!",
color=0x808080)
embed.set_author(
name="Homelands Bot",
url=
r'https://thumbs.dreamstime.com/z/colorful-vector-hand-lettering-banner-spelling-upcoming-events-upcoming-events-hand-drawn-letters-banner-119481161.jpg',
icon_url=
r'https://www.springwaternews.ca/wp-content/uploads/2020/12/upcoming-events.jpg'
)
embed.add_field(
name='--',
value=
f'<@!235148962103951360> Mod bot\n<@!155149108183695360> Mod Bot\n<@!822488670153474098> $help for more details\n<@!487328045275938828> Fun Bot!\n<@!201503408652419073> Music\n'
)
#report() is for reporting users : Ex: $report Someone deleted the report commands
@bot.command()
async def report(ctx,*args):
channel = bot.get_channel(846813361177755648)
report = ''
for message in args:
report += message + " "
await channel.send(f"{ctx.author.mention} reports : {report}")
await ctx.send(f"{ctx.author.mention}, your request has been received. The admins will look over your case.\nKeep in mind : For the best response time, include the perpetrator, reason for report, and message link if valid to make your requests quicker")
#ping() is for people who want to ping the bot
@bot.command()
async def ping(ctx):
start_time = time.time()
await ctx.send("** **")
embed = discord.Embed(title="Pong!", description = f"Response time : \n\nLatency :{bot.latency * 1000} ms\nDiscord API :{(time.time() - start_time) * 1000} ms")
embed.set_footer(text="Written with python")
await ctx.channel.purge(limit=1)
await ctx.send(embed=embed, mention_author=False)
#rev() is for reversing a sentence. Ex: $rev <arg>
@bot.command()
async def rev(ctx, *args):
s = ''
potty_words = [
"faggot",
"bastard",
"whore",
"nigger",
"nigga",
"bitch",
"cunt",
"asshole",
"motherfucker",
"twat",
"fag",
"fuck",
"hoe",
"slut",
"dick"
]
for item in args:
if item not in potty_words:
s += str(item)
s += ' '
stringlength = len(s)
rev_sentence = s[stringlength::-1]
for item in rev_sentence.split(' '):
if item in potty_words:
await ctx.reply("No potty words please")
break
if item not in potty_words:
await ctx.reply(rev_sentence, mention_author=False)
#poll() is for creating a poll. Ex: $poll <arg>
@bot.command()
async def poll(ctx, *args):
if ctx.channel.id == 849714684856238100 or ctx.channel.id == 880096434421125190:
message = ''
num = 0
for item in args:
message += str(args[num]) + " "
num += 1
msg = await ctx.send(f"**{ctx.author}** asks : {message}")
await msg.add_reaction("👍")
await msg.add_reaction("👎")
await ctx.message.delete()
#uniquepoll() is for creating polls with special emojis. Ex: $poll <arg>
@bot.command()
async def uniquepoll(ctx, *args):
if ctx.channel.id == 849714684856238100 or ctx.channel.id == 880096434421125190:
message = ''
num = -1
for item in args:
num += 1
if len(args) - 2 == num:
break
else:
message += str(args[num]) + " "
try:
message = await ctx.send(f"**{ctx.author}** asks : {message}")
await message.add_reaction(str(args[len(args) - 1]))
await message.add_reaction(str(args[int(len(args)) - 2]))
await ctx.message.delete()
except:
await ctx.message.delete()
await message.message.delete()
await ctx.send(
"Not a valid format. Format is `$uniquepoll {prompt} {emoji1} {emoji2}`"
)
#resmessage() is a message if a person goes to prison and is a guilde/resolution message to help them get out of jail.
@bot.command()
async def resmessage(ctx):
if ctx.channel.id == 923714584462884894 or ctx.channel.id == 923020245512384512:
embed = discord.Embed(
title="Welcome to res room",
description=
"<@&907108327962574848> You are in prison because you did something wrong. If you can fix your mistake, fix it before you become a Temporarily Banned Member, kicked or permanently banned. If you cannot, you will suffer either confinement in this prison or receive your due punishment. If you see this message, please fix your mistake in any way you can.\n\n Guidelines :\n 1. What was your mistake\n 2. What will you do so that you won't commit this mistake again? \n 3. Why should you be unmuted?\n\n Answer truthfully. This channel is still moderated, so rules still apply. To resend this message, use command $resmessage"
)
await ctx.channel.send(embed=embed)
#MODERATION
modlist_channels = [
839141157774426142, 846813361177755648, 887097189443207228,
842823949037076520, 880096434421125190, 909529988200554546
]
#post() is for posting. Ex: $post <arg>
#temp out cuz of abuseeeeee :sob:
#@bot.command()
##async def post(ctx,*args):
# message = ''
# num = 0
# for item in args:
# message += str(args[num]) + " "
# num += 1
# await ctx.send("Ping role (Type id). Or type something random or 'None' to ping no roles")
# response = await bot.wait_for('message')
# await ctx.channel.purge(limit=2)
# if response.content.lower() == 'none':
# message = await ctx.send(message)
# else:
# try:
# message = await ctx.send(f"<@&{response.content}> {message}")
# except:
## message = await ctx.send(message)
#
# # actions which should happen if the person responded with 'no' or something els
#await prompt.message.delete()
#await response.message.delete()
# await ctx.message.delete()
#setday() is for changing the day to the day usually tomorrow, for scheduling
@bot.command(aliases=["changeday"])
async def setday(ctx, *args):
if ctx.channel.id in modlist_channels:
from bot_func import setday
try:
set_day = int(args[0])
except:
await ctx.send("Not an integer")
return
if set_day > 5:
await ctx.send("Can't set to that day")
else:
setday(set_day)
await ctx.send(f"Changed day to day {set_day}")
else:
await ctx.send("You can't do that")
#addrole() is used to add a role, usually used for the additon of the @imprisoned role
@bot.command()
async def addrole(ctx, member: discord.Member, role: discord.Role):
if ctx.channel.id in modlist_channels:
await member.add_roles(role)
#react() reacts the checkmark button when a profile name change has been done
@bot.command()
async def react(ctx,*args):
channel = bot.get_channel(907754572179730433)
msg = await channel.fetch_message(str(args[0]))
await msg.add_reaction("✅")
await ctx.message.delete()
#reboot() restarts the entire bot
@bot.command(aliases=['reboot','refresh'])
async def restart(ctx):
if ctx.channel.id in modlist_channels:
await ctx.send("Restarting...")
channel = int(ctx.channel.id)
db["restartctx"] = str(channel) + " " + str(tme.time())
sys.exit()
#Start of the bot
@bot.event
async def on_ready():
#Restart command finished ( Messages the user after restart command has completed)
restartvalue = db['restartctx']
if restartvalue != 0:
#Infection game
if restartvalue == "reboot":
from random import choice
randomuser = choice(bot.users)
channel = bot.get_channel(839135669712060490)
await channel.send(f"<@!{int(db['infected'])}> was infected at the end of the week.")
db['infected'] = int(randomuser.id)
user = await bot.fetch_user(int(db['infected']))
embd = discord.Embed(title = "You have been infected with hehehehaw!",description = "Pass on the hehehehaw to someone else by typing `$infect {user id}` in an channel in the ELC server. Doing so will also remove the hehehehaw from you.\n\nIf you don't know how to get user id:\n\n1.Go to user settings\n2.Click on Advanced\n3.Turn on developer mode\n4.Press the Esc key\n5.Right click a user in the member list on the side and click Copy ID")
await user.send(embed=embd)
db["restartctx"] = 0
else:
cnl = db['restartctx']
cnl = cnl.split()
channel = bot.get_channel(int(cnl[0]))
embd = discord.Embed(title = "Connected",
description = f"Restart finished.\nExecuted in {tme.time() - float(cnl[1])}",
color=discord.Color.green())
await channel.send(embed=embd)
db["restartctx"] = 0
channel = bot.get_channel(919281999427043369)
#CONNECTED MESSAGE#
clock = datetime.now(
pytz.timezone('US/Eastern')).strftime("%m/%d/%y %H:%M:%S")
await channel.send(embed=discord.Embed(
title='Homelands Bot is Online',
description=f"Logged on as {bot.user} as of {clock}",
color=discord.Color.green()))
print('Logged on')
global idling_time
idling_time = 0
background_task.start()
scheduling.start()
global nested
await asyncio.create_task(b_status())
@tasks.loop(seconds=5)
async def scheduling():
global idling_time
global time_status
if idling_time != 0:
idling_time -= 5
else:
#Scheduling for school
from scheduler import scheduler
from subjects import dict705, dict805, dict605, sub
day_of_the_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday','Sunday']
weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
channel = bot.get_channel(919281999427043369)
periods = ['09:00', '09:40', '10:20', '12:00', '12:30', '13:10', '13:50']
holidays = ['03:15','03:16','03:17','03:18','03:19','03:20','04:15','04:18']
now_time = datetime.now(pytz.timezone('US/Eastern')).strftime("%H:%M")
hr = int(datetime.now(pytz.timezone('US/Eastern')).strftime("%H"))
x = datetime.now(pytz.timezone('US/Eastern')).weekday()
day = int(db['day'])
try:
os.remove(r'assets/temp/temp.png')
except:
pass
#Non-school days
if datetime.now(
pytz.timezone('US/Eastern')).strftime("%m:%d") in holidays or day_of_the_week[x] not in weekdays:
time_status = "Holiday. Refresh in a minute."
idling_time = 60
#School days
#School hours
elif hr >=6 and hr <= 14:
channel = bot.get_channel(895778100854546493)
#Start of the day ( 8:30 )
if now_time == '08:30':
file = scheduler()
embed = discord.Embed(
title="Start of school",
description=
f"It is now period 1. \n\n**605 has {dict605[str(day)]['1']}**\n\n**705 has {dict705[str(day)]['1']}**\n\n**805 has {dict805[str(day)]['1']}**\n"
)
embed.add_field(name="Day:", value=day)
embed.set_footer(text="Written with python")
file = discord.File("assets/temp/temp.png",
filename="temp.png")
embed.set_image(url="attachment://temp.png")
print("Sent period 1")
msg = await channel.send(file=file, embed=embed)
await msg.publish()
idling_time = 600
#Lunchtime
elif now_time == '11:00':
file = scheduler()
embed = discord.Embed(title="Lunchtime",
description="Time for lunch! 😋")
embed.add_field(name="Day:", value=day)
embed.set_footer(text="Written with python")
file = discord.File("assets/temp/temp.png",
filename="temp.png")
embed.set_image(url="attachment://temp.png")
print("Sent lunch")
msg = await channel.send(file=file, embed=embed)
await msg.publish()
idling_time = 600
#End of the day ( 2:30 )
elif now_time == '14:30':
file = scheduler()
embed = discord.Embed(title="End of school",
description="Have a nice day!")
embed.add_field(name="Day:", value=day)
embed.set_footer(text="Written with python")
file = discord.File("assets/temp/temp.png",
filename="temp.png")
embed.set_image(url="attachment://temp.png")
#Change the day
from bot_func import changeday
nday = changeday(day)
msg = await channel.send(file=file, embed=embed)
await msg.publish()
#Time
file = scheduler()
#Prompt in the scheduling.
if day_of_the_week[x] == "Friday":
day_prompt = "Monday"
else:
day_prompt = "Tomorrow"
#Send the schedule for tomorrow
embed = discord.Embed(
title=f"Good Afternoon!",
description=
f"{day_prompt}:\n\n605 has:\n {sub(nday,'605')}\n\n705 has:\n {sub(nday,'705')}\n\n805 has: \n {sub(nday,'805')}"
)
embed.add_field(name="Day:", value=nday)
embed.set_footer(text="Written with python")
file = discord.File("assets/temp/temp.png",
filename="temp.png")
embed.set_image(url="attachment://temp.png")
print("Sent the schdule for the next day")
msg = await channel.send(file=file, embed=embed)
await msg.publish()
idling_time = 9000
#School periods
elif now_time in periods:
file = scheduler()
index = periods.index(now_time)
index += 2
embed = discord.Embed(
title=f"Period {index}",
description=
f"It is now period {index}. \n\n**605 has {dict605[str(day)][str(index)]}**\n\n**705 has {dict705[str(day)][str(index)]}**\n\n**805 has {dict805[str(day)][str(index)]}**"
)
embed.add_field(name="Day:", value=day)
embed.set_footer(text="Written with python")
file = discord.File("assets/temp/temp.png",filename="temp.png")
embed.set_image(url="attachment://temp.png")
print(f"Sent school period {index}")
msg = await channel.send(file=file, embed=embed)
await msg.publish()
idling_time = 1500
else:
time_status = "School hours"
else:
time_status = "School day but off school hours"
idling_time = 60
@tasks.loop(seconds=60)
async def background_task():
from startup import timeupdate
if timeupdate() == 'restart':
sys.exit()
global x
global time_status
if bot.is_closed() != True:
print(f"Bot status : Online\n")
else:
print(f"Bot status : Offline\n")
try:
print(time_status)
except:
pass
#Variables
from bot_func import cng_due
from googleapi import main,main2
from bot_func import weatherembed
def refresh():
print("Updated duedates")
#Try and except for tempoarary service errors for Google API
repeat = 0
while True:
if repeat > 2:
break
try:
#Refresh duedates
dueembed = cng_due(main2(), main())
return dueembed
except:
repeat += 1
pass
#Update the weather and duedate embed every 4 and 1 minute(s)
cnl = bot.get_channel(887095059680477214)
message = await cnl.fetch_message(914295454840258601)
try:
await message.edit(embed=refresh())
except:
pass
if int(datetime.now(pytz.timezone('US/Eastern')).strftime("%M")) % 4 == 0:
channel = bot.get_channel(922230146038132816)
message = await channel.fetch_message(922231492296445994)
try:
await message.edit(embed=weatherembed())
except:
pass
if __name__ == "__main__":
#Start
from startup import run
t = Thread(target=run)
t.daemon = True
t.start()
asyncio.get_event_loop().run_until_complete(bot.start(os.environ['discordtoken'],reconnect=True))
sys.exit()