This repository has been archived by the owner on Jan 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththekirbybot.py
2453 lines (2020 loc) · 101 KB
/
thekirbybot.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 discord
from discord.ext import commands
from discord.ext.commands import Bot
import re
from collections import namedtuple, deque
from traceback import print_exc
from typing import Dict
from urllib import parse as url_parse
from urllib import parse
from contextlib import redirect_stdout
import platform
import psutil
import string
import giphypop
import asyncio
import random
import time
import sys
import json
import os
import io
import os.path
import urllib.request
import discord.abc
import aiohttp
import stat
import time
import subprocess
import traceback
import datetime
import praw
import inspect
import textwrap
import weebhooks
from motor.motor_asyncio import AsyncIOMotorClient
from googlesearch import search
import disputils #Some utils
import threading
from context import CustomContext
prefix = "b-"
def randomColor():
clist = ['blue', 'blurple', 'dark_blue', 'dark_gold', 'dark_green', 'dark_grey', 'dark_magenta', 'dark_orange', 'dark_purple', 'dark_red', 'dark_teal', 'darker_grey', 'gold', 'green', 'greyple', 'light_grey', 'lighter_grey', 'magenta', 'orange', 'purple', 'red', 'teal']
return eval(f"discord.Color.{random.choice(clist)}()")
with open('info.json') as f:
config = json.load(f)
botowner = 478675118332051466
with open('tokens.json') as f: # Could use envs, but hopefully someone might land up PRing that.
tokens = json.load(f)
reddit = praw.Reddit(
client_id=tokens["reddit"]["id"],
client_secret=tokens["reddit"]["secret"],
user_agent='Ditto Meme'
)
db = AsyncIOMotorClient(tokens["db"],retryWrites=False).thekirbybotdb
e6login = tokens["e621"]
uaheader = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36'}
async def getprefix(bot,message):
pre = None
if isinstance(message.channel, discord.DMChannel): return '--'
x = await db.prefixes.find_one({ "id": str(message.guild.id) })
try:
if bot.user.id == 538765900841746444:
pre = "b-"
else:
pre = x['prefix']
except:
pre = ['--',f"<@{bot.user.id}> ",f"<@{bot.user.id}>"]
return pre
bot = discord.ext.commands.AutoShardedBot(command_prefix=getprefix, description='A general bot for memes and moderation', pm_help=False, fetch_offline_members=True, activity=discord.Game(name="Starting the bot..."), status=discord.Status("dnd"))
bot.remove_command('help')
GIPHY_TOKEN = tokens["giphy"]
async def status_task():
p = ("--" if bot.user.id == 508268149561360404 else "b-")
games = [
"with a cookie",
"with memes",
"with some speed",
"with a banana",
"with an apple",
"with a cake",
"with a potato",
"with a Maximum Tomato",
f"with {str(len(bot.users))} users",
f"with {str(len(bot.guilds))} servers",
f"with {str(len(bot.commands))} commands",
"with a torch",
"with a Waddle Dee",
"with the devs",
"with Discord's API",
"with other bots",
"with another language",
"with a keyboard",
"with the banland",
"with brackets and quotes",
"Kirby's Nightmare in Dreamland",
"with an interdimensional traveller",
"with Python and Javascript",
"with about 2000 lines of code",
"with the developer's mental sanity",
"with broken code",
"with actual working code",
"with the dev's lives",
"with another bot",
"with a foo bar",
"with a greeting to the world",
"with some Pokemon",
"with Wumpus"
]
while True:
ping_lvl = round(bot.latency * 1000)
if not ping_lvl > 200:
await bot.change_presence(activity=discord.Game(name=f"{random.choice(games)} || Type {p}help for commands"))
else:
await bot.change_presence(activity=discord.Game(name=f"Bot affected by Discord issues."),status=discord.Status.idle)
await asyncio.sleep(20)
nouns = open("list/nouns.txt","r").read().splitlines()
adjectives = open("list/adjectives.txt","r").read().splitlines()
verbs = open("list/verbs.txt","r").read().splitlines()
bot.starttime = 0
@bot.event
async def on_ready():
bot.starttime = time.time()
bot.db = db
bot.commands_run = 0
bot.session = aiohttp.ClientSession()
await bot.change_presence(status=discord.Status("online"))
bot.loop.create_task(status_task())
print("++++++++++++++++++")
print("Succesfully logged in as: " + str(bot.user.name))
print("With an ID of: " + str(bot.user.id))
print("At: " + time.asctime( time.localtime(time.time()) ))
print("Members in total: " + str(len(bot.users)))
print("Servers in total: " + str(len(bot.guilds)))
print("++++++++++++++++++")
#bot.load_extension("music")
if bot.user.id == 508268149561360404:
bot.load_extension('dbl')
bot.load_extension('ddb')
# if os.path.exists("restart.txt"):
# fl = open("restart.txt")
# ids = fl.readlines()
# channel = await bot.get_channel(ids[0])
# await channel.fetch_message(ids[1]).edit("Successfully restarted!")
# fl.close()
# os.remove("restart.txt")
# #
# #
# Commands #
# #
# #
@bot.command(brief="The changelog.",description="Displays everything that has been changed recently.")
async def changelog(ctx):
# changelog = open("changelog.txt",'r')
# Truechangelog = changelog.read()
# await ctx.send(Truechangelog)
# changelog.close()
#Time for the new code ;3
announcements = bot.get_channel(623553307964604417)
message_list = await announcements.history(limit=10).flatten()
last_message = None
for x in message_list:
if x.author.id == 478675118332051466:
last_message = x
break
em = discord.Embed(title="Latest Changelog (announcement)",description=str(last_message.content),color=discord.Color.magenta())
em.set_author(name=last_message.author.name,icon_url=last_message.author.avatar_url)
dt_format = last_message.created_at.strftime("%A %d %B %Y (%H:%M.%S)")
em.set_footer(text=f"Sent at {dt_format}")
await ctx.send(embed=em)
@bot.command(brief="The Support Server!",description="Sends an invite link to the bot's server.")
async def botserver(ctx):
await ctx.send(ctx.message.author.mention + " here you go: " + "https://discord.gg/dcBumZJ")
@bot.command(pass_context=True,brief="Invite the bot to your server!",description="Gives you an invite link to invite the bot to your server.")
async def invite(ctx):
embed=discord.Embed(title="Invite me to your server", url=f"https://discordapp.com/oauth2/authorize?client_id={bot.user.id}&permissions=204811351&scope=bot", color=0x7289da)
embed.set_author(name="The Kirby Bot",icon_url=bot.user.avatar_url)
await ctx.send(embed=embed)
@bot.command(brief="Go to the bot's Patreon.",description="Sends a Patreon link in chat to donate to the bot and help the bot.",aliases=["patreon"])
async def donate(ctx):
await ctx.send("Click here to donate to the bot: https://www.patreon.com/mainuserdrive")
@bot.command(brief="Grabs info on a github repo")
async def github(ctx, repo : str):
buff = await bot.session.get(f"https://api.github.com/search/repositories?q={repo}")
json = await buff.json()
if json["total_count"] == 0:
return await ctx.send("No repos found")
repo = json["items"][0]
em = discord.Embed(title=repo["full_name"],description=repo['description'],color=discord.Color.green())
em.add_field(name="Watchers",value=f"{repo['watchers_count']} watchers")
em.add_field(name="Fork Count",value=f"{repo['forks_count']} forkers")
em.add_field(name="Language",value=f"{repo['language']}")
em.add_field(name="License",value=f"{repo['license']['name']}")
em.set_footer(text="Would add more, but Git's API doesn't have that much.")
await ctx.send(embed=em)
@bot.command(brief="Gets a bunch of bot info, since why not")
async def stats(ctx):
msg = await ctx.send("Getting info... Please wait")
second = round((time.time() - bot.starttime))
minute = round(second / 60)
hour = round(minute / 60)
day = round(hour / 24)
hidden = 0
canrun = 0
nsfw = 0
for command in bot.commands:
if command.hidden:
hidden = hidden + 1
try:
if await command.can_run(ctx):
canrun = canrun + 1
except discord.ext.commands.CommandError:
for ch in command.checks:
if "is_nsfw" in str(ch):
nsfw = nsfw + 1
else:
pass
except Error as e:
raise e
usernames = []
for x in config["SpecialThanks"]:
user = await bot.fetch_user(x)
usernames.append(user.name)
usernames = "\n".join(usernames)
em = discord.Embed(title="Bot Stats",color=0xb50db9)
em.set_author(name=bot.user.name,icon_url=bot.user.avatar_url,url="https://thekirbybot.xyz")
em.add_field(name="Special Thanks",value=f"{usernames}")
em.add_field(name="Uptime",value=f"{day} days, {hour % 24} hours, {minute % 60} minutes, {second % 60} seconds",inline=True)
em.add_field(name="User Count",value=f"{len(bot.users)}",inline=True)
em.add_field(name="Server Count",value=f"{len(bot.guilds)}",inline=True)
em.add_field(name="Commands Run",value=f"{bot.commands_run}",inline=True)
em.add_field(name="Command Count",value=f"{len(bot.commands)} commands in total \n{hidden} admin commands\n{nsfw} NSFW commands hidden\n{len(bot.commands) - canrun - nsfw} commands unable to run (No Permissions)",inline=False)
#Lil var switch here#
second = round((time.time() - psutil.boot_time()))
minute = round(second / 60)
hour = round(minute / 60)
day = round(hour / 24)
em.add_field(name="Being Hosting On",value=f"OS: {platform.system()} {platform.release()}\nSystem Uptime: {day} days, {hour % 24} hours, {minute % 60} minutes, {second % 60} seconds",inline=False)
em.add_field(name="Version Lists",value=f"Python Version: {str(platform.python_version())}\nDiscord.py Version: {discord.__version__}")
ramav = psutil._common.bytes2human(psutil.virtual_memory().available)
ramused = psutil._common.bytes2human(psutil.virtual_memory().used)
em.add_field(name="System Stats",value=f"**--System Wide--**\nCPU Usage: {psutil.cpu_percent()}%\nRAM Available: {ramav}B\nRAM Used: {ramused}B")
em.set_footer(text=f"Bot made with <3 by {discord.utils.get(bot.users,id=478675118332051466)}",icon_url=discord.utils.get(bot.users,id=478675118332051466).avatar_url)
await msg.edit(content=None,embed=em)
@commands.has_permissions(manage_roles = True)
@bot.command(brief="Adds or removes a role from a user, or yourself")
async def role(ctx, user : discord.Member,*,role : discord.Role):
if ctx.author.top_role.position <= user.top_role.position:
return await ctx.send("That person has a higher role than you, so no.")
if role.id in [x.id for x in user.roles]:
await user.remove_roles(role)
await ctx.send(f"Removed **{role.name}** from **{user.display_name}**")
else:
await user.add_roles(role)
await ctx.send(f"Added **{role.name}** to **{user.display_name}**")
@commands.cooldown(1, 30, commands.BucketType.default)
@commands.has_permissions(manage_messages = True)
@bot.command(brief="Cleans an amount of messages (limit 1000) (might lag, do not start another purge while one is in progress)")
async def purge(ctx, number : int = 5,bulk = True):
if number > 1000: return await ctx.send("No, I can not purge more than 1000 messages")
def check(m):
return True
if number <= 100:
await ctx.message.delete()
dele = await ctx.message.channel.purge(limit=number,check=check,bulk=bulk)
return await ctx.send(f"{discord.utils.get(bot.emojis,id=561904367201157121)} Deleted {len(dele)} messages")
deleted = 0
while not number == 0:
if number > 100:
com = await ctx.message.channel.purge(limit=100,check=check,bulk=bulk)
deleted = deleted + len(com)
number = number - 100
else:
com = await ctx.message.channel.purge(limit=number,check=check,bulk=bulk)
deleted = deleted + len(com)
number = number - number
time.sleep(0.1)
await ctx.send(f"{discord.utils.get(bot.emojis,id=561904367201157121)} Deleted {deleted} messages")
@commands.has_permissions(ban_members = True)
@bot.command(brief="Unbans a user from the server",description="(THE COMMAND REQUIRES A PING TO UNBAN (DO THIS BY <@(id)> REPLACING (id) WITH THE USER'S ID))")
async def unban(ctx, user : discord.User,reason : str = "No Reason Provided"):
try:
await ctx.guild.unban(user=user,reason=f"{ctx.author} - {reason}")
await ctx.send(f"Successfully unbanned {user}... They was un-spartan kicked")
except:
await ctx.send("No Ban Found")
@commands.guild_only()
@commands.has_permissions(manage_guild = True)
@bot.command(brief="Sets the prefix in the server")
async def prefix(ctx,*,prefix : str):
bot.db.prefixes.update_one({"id": str(ctx.guild.id)}, {"$set": {"prefix": prefix}}, upsert=True)
await ctx.send(f"The prefix was set to ``{prefix}`` successfully!")
x = await bot.db.modlog.find_one({ "id": ctx.guild.id })
if x:
chnl = bot.get_channel(int(x["channel"]))
if chnl:
em = discord.Embed(title="Prefix Change",color=discord.Color.dark_gold())
em.add_field(name="By",value=ctx.author)
em.add_field(name="New Prefix",value=prefix,inline=False)
await chnl.send(embed=em)
@commands.guild_only()
@commands.has_permissions(manage_guild = True)
@bot.command(brief="Sets the welcome channel for this guild (See --help welcome for format)",description=f"Format:\n" + "{usr} - New Member's Name")
async def welcome(ctx, channel : discord.TextChannel,*, message):
bot.db.welc.update_one({"id": str(ctx.guild.id)}, {"$set": {"message": message, "channel": str(channel.id)}}, upsert=True)
await ctx.send(f"Successfuly changed welcome message to: ``{message}``")
@commands.guild_only()
@commands.has_permissions(manage_guild = True)
@bot.command(brief="Sets the leaving channel for this guild (See --help leave for format)",description=f"Format:\n" + "{usr} - New Member's Name")
async def leave(ctx, channel : discord.TextChannel,*, message):
bot.db.leave.update_one({"id": str(ctx.guild.id)}, {"$set": {"message": message, "channel": str(channel.id)}}, upsert=True)
await ctx.send(f"Successfuly changed leaving message to: ``{message}``")
@commands.guild_only()
@commands.has_permissions(manage_guild=True)
@bot.command(brief="Enables raidmode for the server (See --help raidmode)", description="you do this")
async def raidmode(ctx, option = None):
if option.lower() == "on":
bot.db.raidmode.update_one({"id": str(ctx.guild.id)}, {"$set": {"status": True}}, upsert=True)
return await ctx.send("Raidmode has been enabled. Any users that attempt to join will be kicked.")
elif option.lower() == "off":
bot.db.raidmode.delete_one({"id": str(ctx.guild.id)})
return await ctx.send("Raidmode has been disabled. Users can join now.")
else:
return await ctx.send("Please enter an option: on/off.")
@commands.guild_only()
@bot.command(brief="Shows more info about a certain user",aliases=["ui","u"])
async def userinfo(ctx, user : discord.Member = "plcholder"):
if user == "plcholder":
user = ctx.message.author
emojis = []
#Determine the badges
if user.id in config["Admin"]:
emojis.append(str(discord.utils.get(bot.emojis,id=561904367528312862)))
#Now, the Embed
em = discord.Embed(title=f"User info for {user} {''.join(emojis)}",color=discord.Color.teal())
em.add_field(name="Username",value=str(user.name),inline=True)
em.add_field(name="Discriminator",value=f"#{user.discriminator}",inline=True)
em.add_field(name="ID",value=str(user.id))
if user.nick:
em.add_field(name="Nickname",value=str(user.nick))
#Code to determine what platform
pltfrm = "working"
if str(user.mobile_status) != "offline":
pltfrm = "Mobile"
elif str(user.web_status) != "offline":
pltfrm = "Website"
elif str(user.desktop_status) != "offline":
pltfrm = "Computer"
else:
pltfrm = "placeholder"
#End of determination
em.add_field(name="Status",value=(f"{pltfrm} ({str(user.status).capitalize()})" if pltfrm != "placeholder" else "Offline everywhere"))
if isinstance(user.activity,discord.Spotify):
title = "Playing on Spotify"
gm = f"Song: {user.activity.title}\nBy: {', '.join(user.activity.artists)}\nAlbum: {user.activity.album}"
elif isinstance(user.activity,discord.Streaming):
title = "Streaming"
gm = f"{user.activity.name}"
elif isinstance(user.activity,discord.Game) or isinstance(user.activity,discord.Activity):
title = "Playing"
gm = f"{user.activity.name}"
else:
title = "Playing"
gm = "Not playing anything."
em.add_field(name=title,value=gm)
em.add_field(name="A bot", value=("Yes" if user.bot else "No"))
#Checking if the user has a joined_at attribute
if user.joined_at:
formatted = user.joined_at.strftime("%A %d %B %Y (%H:%M.%S)")
em.add_field(name="Joined the server at",value=formatted)
#Formatting of created_at
fm = user.created_at.strftime("%A %d %B %Y (%H:%M.%S)")
em.add_field(name="Joined Discord at",value=fm)
em.set_footer(text="Userinfo redesign is in beta")
em.set_thumbnail(url=user.avatar_url_as(size=1024))
await ctx.send(embed=em)
@bot.command(brief="Randomly selects the top 20 Reddit submissions on the memes subreddit")
async def meme(ctx):
async with ctx.message.channel.typing():
memes_submissions = reddit.subreddit('memes').hot()
post_to_pick = random.randint(1, 20)
for i in range(0, post_to_pick):
submission = next(x for x in memes_submissions if not x.stickied)
embed=discord.Embed(title=submission.title,color=0xb50db9)
embed.set_image(url=submission.url)
embed.set_footer(text=f"URL: {submission.url}")
await ctx.send(embed=embed)
@bot.command(pass_context=True, brief="DAY BE STEALING MAH BUCKET",aliases=['ohnoes'],description="Sends a bucket meme in chat.")
async def bucket(ctx):
file = discord.File("memes/bucket.jpg", "bucket.jpeg")
await ctx.send(file=file)
@bot.command(brief="Makes👏spaces👏into👏clapping👏emojis👏because👏why👏not",aliases=['memereview'])
async def clap(ctx,*,text):
table = text.split(' ')
em = discord.Embed(title="👏ify")
em.add_field(name="Original Text",value=f"``{text}``")
em.add_field(name="New Text", value=f"``👏{'👏'.join(table)}👏``")
await ctx.send(embed=em)
@bot.command(brief="Sets your AFK status")
async def afk(ctx,*,status : str):
await bot.db.afk.update_one({"id": ctx.author.id}, {"$set": {"status": status}}, upsert=True)
await ctx.send(f"Alright! You are now AFK for ``{status}``.")
@bot.command(brief="Noot Noot!",aliases=['pingu'],description="Sends a random Noot Noot meme in chat.")
async def nootnoot(ctx):
file = discord.File("memes/pingu/nootnoot" + str(random.randint(1,4)) + ".jpg", "pingu.jpeg")
await ctx.send(file=file)
@bot.command(brief="Sends a suggestion to the devs")
async def suggestion(ctx, *, text : str):
svr = bot.get_guild(508305433711083520)
chnl = svr.get_channel(540797383353696266)
suggestionhook.send(f"**Suggestion Recieved**\n``{text}``\nUser: {ctx.author}")
await ctx.send("**Sent the suggestion to the devs!**")
@commands.has_permissions(kick_members = True)
@bot.command(pass_context=True,brief="Kicks a user",description="Kicks a user from your server. The user will be able to rejoin with a new invite link.")
async def kick(ctx, user : discord.Member):
await ctx.guild.kick(user)
choices [
f"**{user.name}** flew off the stage but forgot to recover",
f"**{user.name}** got shown the door",
f"**{user.name}** got their membership permissions revoked",
f"**{user.name}** got oof'd",
f"**{user.name}** got 307'd"
]
await ctx.send(content=random.choice(choices))
@commands.has_permissions(ban_members = True)
@bot.command(pass_context=True,brief="Bans a user",description="Permanently bans a user from your server. Optionally, add the reason at the end of the message")
async def ban(ctx, user : discord.Member,*, reason: str):
await ctx.guild.ban(user,reason=f"Banned by {ctx.author}: {reason}")
choices = [
f"**{user.name}** flew and bit the dust",
f"**{user.name}** found a wild 404 error, and trusted it.",
f"**{user.name}** got game ended",
f"**{user.name}** saw stars and fainted",
f"**{user.name}** was forced to say bye-bye",
f"**{user.name}** decided to see the wrong end of the hammer.",
f"**{user.name}** got Ctrl + Alt + Yeeted (im sorry programmers)",
f"**{user.name}** struck an angry chicken"
]
await ctx.send(content=random.choice(choices))
@commands.has_permissions(ban_members = True)
@bot.command(pass_context=True,brief="Bans a user not in your server",description="Permanently bans a user from your server. Optionally, add the reason at the end of the message")
async def hackban(ctx, user, *, reason: str = "No Reason Provided"):
user_object = discord.Object(int(user))
user_info = await bot.fetch_user(user)
await ctx.guild.ban(user_object,reason=f"Hackbanned by {ctx.author}: {reason}")
await ctx.send(content=f"{str(user_info)} got banned like magic.")
@commands.has_permissions(manage_nicknames = True)
@bot.command(brief="Scans through the members and dehoists them",description="Scans through the members and checks if they have a non-alphabetical character at the start of their nick. If they do, change their nickname.")
async def dehoist(ctx,*, newnick : str = "hoister no hoisting"):
pattern = re.compile('\W')
if not ctx.guild.me.permissions_in(ctx.channel).manage_nicknames:
return await ctx.send("I can not run that because I do not have the Manage Nicknames permission")
count = 0
mlist = []
msg = await ctx.send(f"Alright! Scanning and changing nicknames{bot.get_emoji(528578022748454944)}")
for x in ctx.guild.members:
if re.sub(pattern, '', x.display_name[0]) == "":
try:
pnick = x.display_name
await x.edit(nick=newnick,reason=f"Dehoist Command (Ran by {ctx.author})")
count = count + 1
mlist.append(f"{count}. {x} // {pnick}")
await msg.edit(content=f"Edited {count} nicknames so far. {bot.get_emoji(528578022748454944)}")
except discord.Forbidden:
await ctx.send(f"Failed to change nick of {x} due to lack of permissions..")
except Exception as e:
raise e
if count is not 0:
st = "\n".join(mlist)
x = await bot.session.post("https://hasteb.in/documents",data=f'Format: (username) // (old nickname)\n\n{st}')
buff = await x.json()
await msg.edit(content=f"Changed **{count}** nicknames.\nList: https://hasteb.in/{buff['key']}")
else:
await msg.edit(content=f"No nicknames found. No changes made.")
@bot.command(brief="Gets an Emoji's Information (Must be a custom emoji)",description="Gets information from a custom Discord emoji.")
async def emojiinfo(ctx, emoji : discord.Emoji):
embed=discord.Embed(title="", description="", color=0xb50db9)
embed.set_author(name="The Kirby Bot",icon_url=bot.user.avatar_url)
embed.set_thumbnail(url=emoji.url)
embed.add_field(name="Name", value=emoji.name, inline=True)
embed.add_field(name="ID", value=emoji.id, inline=True)
embed.add_field(name="Require Colons?", value=str(emoji.require_colons), inline=True)
embed.add_field(name="Twitch Managed?", value=str(emoji.managed), inline=True)
embed.add_field(name="Server", value=str(emoji.guild.name), inline=True)
embed.add_field(name="Created At", value=str(emoji.created_at), inline=True)
await ctx.send(embed=embed)
@commands.cooldown(1, 30, commands.BucketType.default)
@bot.command(pass_context=True,brief="Send a message to the bot developers about the bot",description="Sends a message to the bot developers about the bot")
async def devmsg(ctx, *, msg):
await ctx.send("**Succesfully sent your message to the devs:white_check_mark:**")
chnl = bot.get_channel(558699099331756043)
embed=discord.Embed(title="**Developer Message**", description=msg, color=0xb50db9)
embed.add_field(name="Sent By", value=f"{ctx.author.name}#{ctx.author.discriminator}", inline=False)
embed.add_field(name="Server:", value=ctx.message.guild.name, inline=False)
embed.set_footer(text=f"Time Sent: {time.asctime(time.localtime(time.time()))}")
await chnl.send(embed=embed)
@commands.cooldown(1,10,commands.BucketType.default)
@bot.command(brief="Retrieves the time the bot can communicate with Discord")
async def ping(ctx):
edittime = time.time()
pingtime = round(bot.latency * 1000,2)
nekoslife = "Retrieving nekos.life response time.."
furrybot = "Retrieving furry.bot response time.."
msg = await ctx.send("Pinging in the 90s, its a new place you want to be!")
embed=discord.Embed(title="", url="", description="",color=randomColor())
embed.set_author(name=bot.user.name,icon_url=bot.user.avatar_url)
embed.add_field(name="Ping!", value=f"{pingtime}ms Latency\nRetrieving edit time...\n{nekoslife}\n{furrybot}", inline=False)
await msg.edit(content=None,embed=embed)
edittime = round((time.time() - edittime) * 100,2)
embed.set_field_at(index=0,name="Ping!",value = f"{pingtime}ms Latency\n{edittime}ms Edit Latency\n{nekoslife}\n{furrybot}")
await msg.edit(content=None,embed=embed)
#Getting nekos.life response time#
try:
nekoslife = time.time()
buff = await bot.session.get("https://nekos.life/api/v2/img/bj")
json = await buff.json()
nekoslife = f"{round((time.time() - nekoslife) * 100,2)}ms Response time (nekos.life)"
except Exception as e:
nekoslife = "Unable to get nekos.life response time."
embed.set_field_at(index=0,name="Ping!",value = f"{pingtime}ms Latency\n{edittime}ms Edit Latency\n{nekoslife}\n{furrybot}")
await msg.edit(content=None,embed=embed)
#Getting furry.bot response time#
try:
furrybot = time.time()
buff = await bot.session.get("https://api.furry.bot/furry/nsfw/yiff/gay") #Use an NSFW endpoint for the memes
json = await buff.json()
furrybot = f"{round((time.time() - furrybot) * 100,2)}ms Response time (furry.bot)"
except Exception as e:
furrybot = "Unable to get furry.bot response time."
embed.set_field_at(index=0,name="Ping!",value = f"{pingtime}ms Latency\n{edittime}ms Edit Latency\n{nekoslife}\n{furrybot}")
await msg.edit(content=None,embed=embed)
@commands.has_permissions(administrator = True)
@bot.command(brief="Changes nickname of everyone the bot can change",description="**WARNING: CAN BE HIGHLY DESTRUCTIVE!**")
async def massnick(ctx,*,nick : str = None):
try:
if len(nick) > 32:
return await ctx.send(f"Nickname is too large. It must be under 32 letters (it is currently {len(nick)} letters long)")
except TypeError: #Just in case it is None
pass
except Exception as e:
raise e
#Now time for the "destructive" part. Oh lord.
msg = await ctx.send("Changing nicknames...")
mlist = []
count = 0
for x in ctx.guild.members:
try:
await x.edit(nick=nick,reason=f"Massnick command ran by {ctx.author}")
count = count + 1
mlist.append(f"{count}. {x.name} {(f'({ctx.author.display_name})' if ctx.author.nick else '')} changed.")
except discord.Forbidden:
count = count + 1
mlist.append(f"{count}. {x.name} {(f'({ctx.author.display_name})' if ctx.author.nick else '')} failed: Hoist role is lower than theirs.")
pass
except Exception as e:
raise e
await msg.edit(content=f"**{count}** nicknames changed (Last changed: ``{x.display_name}``)")
#And then, beautiful, beautiful hastebin code
st = "\n".join(mlist)
x = await bot.session.post("https://hasteb.in/documents",data=f"List of nicknames changed in {ctx.guild.name}\n\n{st}")
buff = await x.json()
await msg.edit(content=f"All finished!\n**Results: https://hasteb.in/{buff['key']}*")
@bot.command()
async def weather(ctx,*, cityname):
async with ctx.message.channel.typing():
try:
res = await bot.session.get(f"https://api.openweathermap.org/data/2.5/weather?APPID={tokens['weathermap']}&q={cityname}")
x = await res.json()
em = discord.Embed(title=f"Weather for {x['name']}, {x['sys']['country']}",description=f"ID: {x['id']}",color=discord.Color.dark_blue())
em.add_field(name="🍃Wind Speed",value=f"{x['wind']['speed']}m/s")
em.add_field(name="☁Cloud Percentage",value=f"{x['clouds']['all']}%")
em.add_field(name="🌡Temp. Now",value=f"{round((x['main']['temp'] - 273.15),2)}**C**\n{round(((x['main']['temp'] - 273.15) * 9/5 + 32),2)}**F**")
em.add_field(name="🌊Humidity",value=f"{x['main']['humidity']}%")
time = datetime.datetime.utcfromtimestamp(x['sys']['sunrise']).strftime("%I:%M.%S%p %Z")
em.add_field(name="🌄Sunrise Time",value=time)
time = datetime.datetime.utcfromtimestamp(x['sys']['sunset']).strftime("%I:%M.%S%p %Z")
em.add_field(name="🌇Sunset Time",value=time)
em.set_footer(text="Data from openweathermap.org")
except KeyError:
await ctx.send("No city found. Did you make a typo?")
except Exception as e:
raise e
await ctx.send(embed=em)
@bot.command(brief="Makes a fake Trump tweet.", description="Generates a Trump tweet from an API and sends it in chat.")
async def trump(ctx,*, text : str = "i wanna build a wall"):
async with ctx.message.channel.typing():
res = await bot.session.get(f"https://nekobot.xyz/api/imagegen?type=trumptweet&text={text}")
x = await res.json()
em = discord.Embed(title="Trump tweets something",color=discord.Color.dark_magenta())
em.set_image(url=x["message"])
em.set_footer(text="Powered by nekobot.xyz")
await ctx.send(embed=em)
@bot.command(brief="Makes a 'change my mind' image")
async def changemind(ctx,*, text : str = "Youtube Rewind was bad"):
async with ctx.message.channel.typing():
res = await bot.session.get(f"https://nekobot.xyz/api/imagegen?type=changemymind&text={text}")
x = await res.json()
url = x["message"]
res = await bot.session.get(url)
em = discord.Embed(title=f"{ctx.author.name} wants their mind changing",color=discord.Color.dark_magenta())
em.set_image(url=url)
em.set_footer(text="Powered by nekobot.xyz")
await ctx.send(embed=em)
@bot.command(brief="Gets information on a Roblox user's profile (ID Only)",alises=['rbl'])
async def roblox(ctx,*,user : int):
try:
res = await bot.session.get(f"https://api.roblox.com/users/{user}")
x = await res.json()
groups = await bot.session.get(f"https://api.roblox.com/users/{user}/groups")
groups = await groups.json()
fmt = ""
for group in groups:
fmt = fmt + f"\n{group['Name']} ({group['Id']})"
except:
return await ctx.send("Player not found")
em = discord.Embed(title=f"{discord.utils.get(bot.emojis,id=608793165885079571)}Information for {x['Username']}{discord.utils.get(bot.emojis,id=608793165885079571)}",color=discord.Color.red())
em.add_field(name="ID",value=x['Id'])
em.add_field(name="Groups",value=(fmt if not fmt == "" else "No Groups Found (Either the endpoint is down, or the user is in no groups)"))
em.set_thumbnail(url=f"https://www.roblox.com/Thumbs/Avatar.ashx?x=500&y=500&userId={x['Id']}")
await ctx.send(embed=em)
@bot.command(brief="Searches discordsbestbots.xyz for a bot",aliases=["dbb","dbbsearch","botsearch"])
async def discordbotsearch(ctx,*, botn: str = None):
async with ctx.message.channel.typing():
if botn == None:
return await ctx.send("Bot name is required!")
res = await bot.session.get(f"https://discordsbestbots.xyz/api/search?type=bot&search={botn}")
searchjson = None
try:
searchjson = (await res.json())["bots"][0]
except:
return await ctx.send("No bots were found, or the site is down!")
req = await bot.session.get(f"https://discordsbestbots.xyz/api/bots/{(searchjson['vanityUrl'] if searchjson['trusted'] else searchjson['_id'])}")
botjson = ((await req.json())['bot'])
em = discord.Embed(description=botjson["shortDesc"],color=discord.Color.teal())
em.set_author(name=f"Info for {botjson['member']['user']['username']}#{botjson['member']['user']['discriminator']}",icon_url=botjson['member']['user']["displayAvatarURL"])
em.add_field(name="Prefix",value=botjson["prefix"])
em.add_field(name="Library",value=botjson["lang"])
em.add_field(name="Github",value=(botjson["github"] if not botjson["github"] == "" else "No Github Linked"))
em.add_field(name="Twitter",value=(botjson["twitter"] if not botjson["twitter"] == "" else "No Twitter Linked"))
em.add_field(name="Website",value=(botjson["website"] if not botjson["website"] == "" else "No Website Linked"))
#Do a little dance to append all owners into a format
emojis = ""
owners = []
if botjson['owner']["trustedDev"] == True: emojis = emojis + str(discord.utils.get(bot.emojis,id=559115961421266965))
if botjson['owner']["mod"] == True: emojis = emojis + str(discord.utils.get(bot.emojis,id=559115961475792898))
if botjson['owner']["admin"] == True: emojis = emojis + str(discord.utils.get(bot.emojis,id=559115961408552962))
owners.append(f"{botjson['owner']['user']['username']}#{botjson['owner']['user']['discriminator']} {(emojis if not emojis == '' else '')}")
for x in botjson["owners"]:
emojis = ""
if x["trustedDev"] == True: emojis = emojis + str(discord.utils.get(bot.emojis,id=559115961421266965))
if x["mod"] == True: emojis = emojis + str(discord.utils.get(bot.emojis,id=559115961475792898))
if x["admin"] == True: emojis = emojis + str(discord.utils.get(bot.emojis,id=559115961408552962))
owners.append(f"{x['user']['username']}#{x['user']['discriminator']} {(emojis if not emojis == '' else '')}")
#Stop the dance since we formatted the owners
em.add_field(name="Owners",value="\n".join(owners))
em.add_field(name="Stats",value=(f"Guilds: {botjson['stats']['guilds']}\nShards: {botjson['stats']['shards']}"))
em.add_field(name="Verified",value=f"{('Verified' if botjson['verified'] else 'Unverified')} ({('In Server' if botjson['inGuild'] else 'Not In Server')})")
em.add_field(name="Trusted",value=("Yes" if botjson["trusted"] else "No"))
em.add_field(name="Server",value=(botjson["server"] if botjson["server"] else "No Server Set"))
em.add_field(name="Votes",value=f"Monthly Votes: {botjson['monthlyVotes']}\nTotal Votes: {botjson['totalVotes']}")
try:
em.add_field(name="NSFW",value=("Yes" if botjson["nsfw"] else "No"))
except:
em.add_field(name="NSFW",value="No")
em.set_footer(text=f"Bot page: https://discordsbestbots.xyz/bots/{(botjson['vanityUrl'] if botjson['trusted'] else botjson['_id'])}")
em.set_image(url=(botjson["bg"] if not botjson["bg"] == "" else "https://pixelpikachu.tk/DXfAHOkI.png"))
await ctx.send(embed=em)
@bot.command(brief="Modifies the modlog settings for the server ", description="Coded by: dat banana boi")
@commands.has_permissions(manage_guild=True)
async def modlog(ctx, channel): #i knew this was a bad idea
if channel.lower() == "off" or channel.lower() == "disable":
find = await bot.db.modlog.find_one({"id": ctx.guild.id})
if not find:
return await ctx.send("Modlogs were never on.")
else:
await bot.db.modlog.delete_one({"id": ctx.guild.id})
await ctx.send("Modlogs have been turned OFF now.")
else:
chan = bot.get_channel(int(channel.strip("<#").strip(">"))) # revert to original
await bot.db.modlog.update_one({"id": ctx.guild.id}, {"$set": {"channel": chan.id}}, upsert=True) #Chiki-chan~
await ctx.send(f"Modlogs are now turned ON in {chan.mention}. Enjoy!") #Now events
@bot.command(brief="Gets someone's avatar",aliases=["av"])
async def avatar(ctx,user : discord.User = "plc"):
if user == "plc":
user = ctx.author
em = discord.Embed(title=f"{user}'s Avatar",color=randomColor())
em.set_image(url=user.avatar_url_as(size=1024))
await ctx.send(embed=em)
@bot.command(brief="Posts some text to Hastebin",aliases=['hb'])
async def hastebin(ctx,*,text : str = "http://www.script-o-rama.com/movie_scripts/a1/bee-movie-script-transcript-seinfeld.html"):
x = await bot.session.post("https://hasteb.in/documents",data=str(text))
buff = await x.json()
await ctx.send(f"Sent the text to Hastebin!\nhttps://hasteb.in/{buff['key']}")
@commands.is_nsfw() #DDB staff asked me to
@bot.command(brief="Googles a query for you",aliases=['g'])
async def google(ctx,*,text : str):
async with ctx.message.channel.typing():
re = search(query=text,tld='com',num=3,stop=3,safe=False,pause=2)
st = []
for s in re:
st.append(f"<{s}>")
fmt = '\n'.join(st)
await ctx.send(f"Here are the top 3 results from a search:\n{fmt}")
@bot.command(brief="Gets a LMGTFY link for you",aliases=['letmegoogle','lmg'])
async def lmgtfy(ctx,*,text : str):
text = text.split(' ')
await ctx.send(f"http://lmgtfy.com/?q={'+'.join(text)}")
@bot.command(brief="Ships two users together")
async def ship(ctx, user : discord.Member, user2 : discord.Member):
randomin = random.randint(0,100)
fmt = ""
if user == user2 or user2 == user:
return await ctx.send("I cant ship the same person...")
if (user.id == 478675118332051466 or user.id == 468785679036317699) and (user.id == 478675118332051466 or user.id == 468785679036317699):
randomin = 100
em = discord.Embed(title=f"{user.display_name} x {user2.display_name}",color=randomColor())
if randomin >= 0:
fmt = "Eeeeeeehhhhhhh..."
if randomin >= 10:
fmt = "Best as just friends.."
if randomin >= 20:
fmt = "Could be something.."
if randomin >= 30:
fmt = "Special... Possible crushes?"
if randomin >= 40:
fmt = "Should date..."
if randomin >= 50:
fmt = "Come on... I know one of you loves the other one"
if randomin >= 60:
fmt = "Needs some improvements..."
if randomin == 69:
if ctx.channel.nsfw:
fmt = "*moans* your cock is so erect... >.<"
else:
fmt = "Hot and steamy..."
if randomin >= 70:
fmt = "A good couple"
if randomin >= 80:
fmt = "Just about perfect"
if randomin >= 90:
fmt = "Perfect couple!"
em.add_field(name=f"{randomin}%",value=fmt)
em.add_field(name="Ship Name",value=f"{(str(user.name))[:int(len((str(user.name))) / 2)] + (str(user2.name))[int(len((str(user2.name))) / 2):]}",inline=False)
em.set_thumbnail(url=user.avatar_url_as(size=1024))
em.set_footer(text="Will make the image better once the bot has access to image manipulation")
await ctx.send(embed=em)
@bot.command(brief="Gets a random noun, adjective and verb from the English dictionary",aliases=['rg','ranwords'])
async def randomgrammar(ctx):
async with ctx.message.channel.typing():
await ctx.send(f"Noun: ``{random.choice(nouns)}``\nVerb: ``{random.choice(verbs)}``\nAdjective: ``{random.choice(adjectives)}``")
@bot.command(brief="Gets the top 15 servers the bot is in",aliases=["topservers","ts","tg"])
async def topguilds(ctx):
sortlist = sorted(bot.guilds,key=lambda x: len(x.members),reverse=True)
l = []
for x in sortlist[0:14]:
l.append(f"**{len(x.members)} members** - {x.name}")
em = discord.Embed(title="Top 15 servers (Listed by member order)",description="\n".join(l),color=randomColor())
await ctx.send(embed=em)
@bot.command(brief="Gives someone a lil' cuddle")
async def cuddle(ctx, user : discord.Member = "plc"):
if user == "plc":
user = ctx.author
useAnime = not await bot.db.allowFurryList.find_one({"id": ctx.guild.id})
buff = await bot.session.get(("https://nekos.life/api/v2/img/cuddle" if useAnime else "https://api.furry.bot/furry/sfw/cuddle"))
json = await buff.json()
em = discord.Embed(title=(f"{ctx.author.name} cuddled {user.name}! They're so cute!" if not ctx.author == user else f"Its okay {ctx.author.name}, I'll cuddle you"),color=discord.Color.dark_blue())
em.set_image(url=(json['url'] if useAnime else json['response']['image']))
em.set_footer(text=f"Powered by {('nekos.life' if useAnime else 'furry.bot')}")
await ctx.send(embed=em)
@bot.command(brief="Gives someone a lil' hug")
async def hug(ctx, user : discord.Member = "plc"):
if user == "plc":
user = ctx.author
useAnime = not await bot.db.allowFurryList.find_one({"id": ctx.guild.id})
buff = await bot.session.get(("https://nekos.life/api/v2/img/hug" if useAnime else "https://api.furry.bot/furry/sfw/hug"))
json = await buff.json()
em = discord.Embed(title=(f"{ctx.author.name} just gave {user.name} a hug OwO" if not ctx.author == user else f"Its okay {ctx.author.name}, I'll hug you"),color=discord.Color.dark_blue())
em.set_image(url=(json['url'] if useAnime else json['response']['image']))
em.set_footer(text=f"Powered by {('nekos.life' if useAnime else 'furry.bot')}")
await ctx.send(embed=em)
@bot.command(brief="Gives someone a kiss")
async def kiss(ctx, user : discord.Member = "plc"):
if user == "plc":
user = ctx.author
useAnime = not await bot.db.allowFurryList.find_one({"id": ctx.guild.id})
buff = await bot.session.get(("https://nekos.life/api/v2/img/kiss" if useAnime else "https://api.furry.bot/furry/sfw/kiss") )
json = await buff.json()
em = discord.Embed(title=(f"{ctx.author.name} just kissed {user.name}! Can I ship them?" if not ctx.author == user else f"Its ok... Have a kiss {ctx.author.name}"),color=discord.Color.dark_blue())
em.set_image(url=(json['url'] if useAnime else json['response']['image']))
em.set_footer(text=f"Powered by {('nekos.life' if useAnime else 'furry.bot')}")
await ctx.send(embed=em)
@bot.command(brief="Grabs a random dog")
async def dog(ctx):
buff = await bot.session.get("https://nekos.life/api/v2/img/woof")
json = await buff.json()
em = discord.Embed(title="Random Dog",color=discord.Color.purple())
em.set_image(url=json['url'])
em.set_footer(text="Powered by nekos.life")
await ctx.send(embed=em)
@bot.command(brief="Grabs a random cat")
async def cat(ctx):
buff = await bot.session.get("https://nekos.life/api/v2/img/meow")
json = await buff.json()
em = discord.Embed(title="Random Cat",color=discord.Color.purple())
em.set_image(url=json['url'])
em.set_footer(text="Powered by nekos.life")
await ctx.send(embed=em)