Skip to content

Commit

Permalink
Added cogs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mastermind-sap authored Apr 8, 2021
1 parent 1cbfae0 commit d69a023
Show file tree
Hide file tree
Showing 26 changed files with 1,012 additions and 0 deletions.
Binary file added cogs/__pycache__/akinator.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/chess.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/conversation.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/events.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/example.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/fun.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/help.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/mastermind.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/music.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/restricted.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/riddle.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/server.cpython-38.pyc
Binary file not shown.
Binary file added cogs/__pycache__/utility.cpython-38.pyc
Binary file not shown.
84 changes: 84 additions & 0 deletions cogs/akinator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import discord
from discord.ext import commands,tasks
import akinator as ak
import random
import requests
import json
import asyncio
import itertools


class Akinator(commands.Cog):
def __init__(self,bot):
self.bot=bot

@commands.command(aliases=["aki"])
async def akinator(self,ctx):
intro=discord.Embed(title="Akinator",description="Hello, "+ctx.author.mention+"I am Akinator!!!",color=discord.Colour.blue())
intro.set_thumbnail(url="https://en.akinator.com/bundles/elokencesite/images/akinator.png?v93")
intro.set_footer(text="Think about a real or fictional character. I will try to guess who it is")
bye=discord.Embed(title="Akinator",description="Bye, "+ctx.author.mention,color=discord.Colour.blue())
bye.set_footer(text="Akinator left the chat!!")
bye.set_thumbnail(url="https://i.pinimg.com/originals/28/fc/0b/28fc0b88d8ded3bb8f89cb23b3e9aa7b.png")
await ctx.send(embed=intro)
def check(msg):
return msg.author == ctx.author and msg.channel == ctx.channel and msg.content.lower() in ["y", "n","p","b","yes","no","probably","idk","back"]
try:
aki = ak.Akinator()
q = aki.start_game()
while aki.progression <= 80:
question=discord.Embed(title="Question",description=q,color=discord.Colour.blue())
ques=["https://i.imgflip.com/uojn8.jpg","https://ih1.redbubble.net/image.297680471.0027/flat,750x1000,075,f.u1.jpg"]
question.set_thumbnail(url=ques[random.randint(0,1)])
question.set_footer(text="Your answer:(y/n/p/idk/b)")
question_sent=await ctx.send(embed=question)
try:
msg = await self.bot.wait_for("message", check=check , timeout=30)
except asyncio.TimeoutError:
await question_sent.delete()
await ctx.send("Sorry you took too long to respond!(waited for 30sec)")
await ctx.send(embed=bye)
return
await question_sent.delete()
if msg.content.lower() in ["b","back"]:
try:
q=aki.back()
except ak.CantGoBackAnyFurther:
await ctx.send(e)
continue
else:
try:
q = aki.answer(msg.content.lower())
except ak.InvalidAnswerError as e:
await ctx.send(e)
continue
aki.win()
answer=discord.Embed(title=aki.first_guess['name'],description=aki.first_guess['description'],color=discord.Colour.blue())
answer.set_thumbnail(url=aki.first_guess['absolute_picture_path'])
answer.set_image(url=aki.first_guess['absolute_picture_path'])
answer.set_footer(text="Was I correct?(y/n)")
await ctx.send(embed=answer)
#await ctx.send(f"It's {aki.first_guess['name']} ({aki.first_guess['description']})! Was I correct?(y/n)\n{aki.first_guess['absolute_picture_path']}\n\t")
try:
correct = await self.bot.wait_for("message", check=check ,timeout=30)
except asyncio.TimeoutError:
await ctx.send("Sorry you took too long to respond!(waited for 30sec)")
await ctx.send(embed=bye)
return
if correct.content.lower() == "y":
yes=discord.Embed(title="Yeah!!!",color=discord.Colour.blue())
yes.set_thumbnail(url="https://i.pinimg.com/originals/ae/aa/d7/aeaad720bd3c42b095c9a6788ac2df9a.png")
await ctx.send(embed=yes)
else:
no=discord.Embed(title="Oh Noooooo!!!",color=discord.Colour.blue())
no.set_thumbnail(url="https://i.pinimg.com/originals/0a/8c/12/0a8c1218eeaadf5cfe90140e32558e64.png")
await ctx.send(embed=no)
await ctx.send(embed=bye)
except Exception as e:
await ctx.send(e)




def setup(bot):
bot.add_cog(Akinator(bot))
71 changes: 71 additions & 0 deletions cogs/chess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import discord
from discord.ext import commands,tasks
import chessdotcom as chess
import random
import requests
import json
import asyncio
import itertools


class Chess(commands.Cog):
def __init__(self,bot):
self.bot=bot



@commands.command(aliases=["chessprofile"])
async def get_player(self,ctx,*,username):
try:
data = chess.get_player_profile(username).json
data1=chess.is_player_online(username).json
data2=chess.get_player_clubs(username).json
profile=discord.Embed(title=data['username'],description=data['name'] if 'name' in data else "No name given",color=discord.Colour.red())
profile.set_thumbnail(url=data['avatar'] if 'avatar' in data else "https://betacssjs.chesscomfiles.com/bundles/web/images/noavatar_l.1c5172d5.gif")
profile.add_field(name="Country:",value=data['country'],inline=False)
profile.add_field(name="Followers:",value=data['followers'],inline=False)
profile.add_field(name="Status:",value=data['status'],inline=False)
profile.add_field(name="Online:",value="Yes" if data1['online'] else "No",inline=False)
profile.add_field(name="Url:",value=data['url'],inline=False)
for i in data2['clubs']:
profile.add_field(name="Club:",value=i['name'],inline=False)
await ctx.send(embed=profile)
except Exception as e:
print(e)
await ctx.send("Username doesnot exist")

@commands.command(aliases=["leaderboards"])
async def print_leaderboards(self,ctx):
await ctx.send("Leaderboards")
data = chess.get_leaderboards().json
categories = data.keys()
for category in categories:
await ctx.send('Category:'+str(category))
for idx, entry in enumerate(data[category]):
if idx<3:
await ctx.send(f'Rank: {idx + 1} | Username: {entry["username"]} | Rating: {entry["score"]}')
else:
break
@commands.command(aliases=["stats"])
async def get_player_rating(self,ctx,*,username):
await ctx.send("Player Ratings")
data = chess.get_player_stats(username).json
categories = ['chess_blitz', 'chess_rapid', 'chess_bullet']
for category in categories:
await ctx.send('Category:'+str(category))
await ctx.send(f'Current: {data[category]["last"]["rating"]}')
await ctx.send(f'Best: {data[category]["best"]["rating"]}')
await ctx.send(f'Record: {data[category]["record"]}')

@commands.command()
async def chesspuzzle(self,ctx):
await ctx.send("Random Puzzle")
data = chess.get_random_daily_puzzle().json
await ctx.send(data['title'])
await ctx.send(data['image'])
await ctx.send(data['url'])



def setup(bot):
bot.add_cog(Chess(bot))
116 changes: 116 additions & 0 deletions cogs/conversation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import discord
from discord.ext import commands,tasks
import random
import requests
import json
import asyncio
import itertools

hi_urls=["https://media.tenor.com/images/89875b33e32cdd0d1777553653a6717c/tenor.gif",
"https://media.tenor.com/images/852dab1b47145c779f3266a9ac76d922/tenor.gif",
"https://media.tenor.com/images/18e364be2476610c0c760a631c63416e/tenor.gif",
"https://media.tenor.com/images/fe3e2d08c49445ca807935eba60e5627/tenor.gif",
"https://media.tenor.com/images/5fbe85446cdfa0c3ce15b1e4ddc58c37/tenor.gif",
"https://media.tenor.com/images/1ab4a2bf24e962b03c27a4c8352c3e2f/tenor.gif",
"https://media.tenor.com/images/1ee82bdcacdbc8ec55443a349ac1ef03/tenor.gif",
"https://media.tenor.com/images/e6afa2be25c23e4c6f82f6e2faeb3400/tenor.gif"]
uthere_urls=["https://media.tenor.com/images/fa2e94e3d890184f667cf9d0a381a213/tenor.gif",
"https://media.tenor.com/images/e27c3c608e5502accd4853d343be876c/tenor.gif",
"https://media.tenor.com/images/fae3cdddd0ca0a75b4fee69188d84e67/tenor.gif",
"https://media.tenor.com/images/fb438267a923f041ab3b8d5ef2c2e2a4/tenor.gif",
"https://media.tenor.com/images/843febaec8b2476756038d8300b6c861/tenor.gif",
"https://media.tenor.com/images/8073fab909716c5cbebfdb6bcc86af71/tenor.gif",
"https://media.tenor.com/images/9ea44380b5ba010d2e40f321da1564a9/tenor.gif"]
insult_urls=["https://media.tenor.com/images/19c50486ee6b472aba2817024c5ee4a5/tenor.gif",
"https://media.tenor.com/images/2141dce8c8a73632749ede31cb6dd215/tenor.gif",
"https://media.tenor.com/images/7397ff5d71c043634233a2be91053d8a/tenor.gif",
"https://media.tenor.com/images/14cf6a44d0bd56f95eab06051c2c8bfd/tenor.gif",
"https://media.tenor.com/images/256b5c5dc88a7c74f010ee0505d931ee/tenor.gif",
"https://media.tenor.com/images/bc0fd16a9423fbe24127f8cccf247846/tenor.gif",
"https://media.tenor.com/images/e8713cf0d9b7fc9d03215c394b8ffa0b/tenor.gif",
"https://media.tenor.com/images/ba01b4ab2950342c129876164aa2d70d/tenor.gif"]
gm_urls=["https://media.tenor.com/images/027da4b11ab91e5c0dffb388a8c6f060/tenor.gif",
"https://media.tenor.com/images/84a8c2f0a681c3fc7db9b7084122d5a1/tenor.gif",
"https://media.tenor.com/images/c591a3e438a4249775bf00457b915793/tenor.gif",
"https://media.tenor.com/images/2890b109fc92eff030d1c24db0d2a761/tenor.gif",
"https://media.tenor.com/images/5852b06765c604372f640218b4e24b3d/tenor.gif",
"https://media.tenor.com/images/8e9f35f9648ab4256531dde31de09a9f/tenor.gif",
"https://media.tenor.com/images/8f4a3f2f406ecccc8f790d63e5c94e3e/tenor.gif"]
gn_urls=["https://media.tenor.com/images/dec42b8d70a58a62cf106ecac1023d60/tenor.gif",
"https://media.tenor.com/images/ccd68c7c41800fb7090eced436a1bda0/tenor.gif",
"https://media.tenor.com/images/ef780440dce0fe33dedf9ca205f2ca1c/tenor.gif",
"https://media.tenor.com/images/106064f0a356423af9e2ac51bef3409a/tenor.gif",
"https://media.tenor.com/images/819d5eb6ae504c1b94eacdfa13878688/tenor.gif",
"https://media.tenor.com/images/4a92c3367012116430b31d2315a5b701/tenor.gif",
"https://media.tenor.com/images/2e89a44860147edcc6349ed3da9c234f/tenor.gif"]
bye_urls=["https://media.tenor.com/images/5becc8db5702cc2f9affea9559f10cd1/tenor.gif",
"https://media.tenor.com/images/e955f55bab6839ec724531e3bae3303c/tenor.gif",
"https://media.tenor.com/images/0f5b101d294b217d13b3badb43c38fa0/tenor.gif",
"https://media.tenor.com/images/217be23d6af58e44d7e0fb48595815bd/tenor.gif",
"https://media.tenor.com/images/93106f99ea2f7638fa0a49af0dc1bd9c/tenor.gif",
"https://media.tenor.com/images/80534b478b519f315230d7d1c993a326/tenor.gif",
"https://media.tenor.com/images/bb2599195ea28683463badc924f01c81/tenor.gif",
"https://media.tenor.com/images/a13b5ae7e6efa9391c2feacaaeaf5656/tenor.gif",
"https://media.tenor.com/images/9c6383ca347da05c30cc4dbb986d1ca2/tenor.gif",
"https://media.tenor.com/images/9b282281b97686e155961a542dc57f87/tenor.gif",
"https://media.tenor.com/images/a211545ceb0e837aba11287fae0b4dce/tenor.gif"]


class Greetings(commands.Cog):
def __init__(self,bot):
self.bot=bot

@commands.command(aliases=["hi"])
async def hello(self,ctx, member : discord.Member = None):
if not member:
member = ctx.author
await ctx.send('Hello! '+member.mention)
await ctx.send(random.choice(hi_urls))

@commands.command(aliases=["uthere"])
async def areuthere(self,ctx, user : discord.Member = None):
if not user:
user=ctx.author
await ctx.send('Are You There? '+user.mention)
await ctx.send(random.choice(uthere_urls))

@commands.command()
async def insult(self,ctx, user : discord.Member =None):
if not user:
user=ctx.author
await ctx.send('Insulting'+user.mention)
await ctx.send(random.choice(insult_urls))

@commands.command(aliases=["destroy"])
async def troll(self,ctx, user : discord.Member =None):
if not user:
user=ctx.author
url = "https://evilinsult.com/generate_insult.php?lang=en&type=txt"
st = requests.get(url)
await ctx.send(str(user.mention)+st.content.decode("utf-8"))

@commands.command(aliases=["gm"])
async def goodmorning(self,ctx, user : discord.Member =None):
if not user:
user=ctx.author
await ctx.send('Good Morning! '+user.mention)
await ctx.send(random.choice(gm_urls))

@commands.command(aliases=["goodn8","nightynight","gn"])
async def goodnight(self,ctx, user : discord.Member =None):
if not user:
user=ctx.author
await ctx.send('Good Night! '+user.mention)
await ctx.send(random.choice(gn_urls))

@commands.command(aliases=["sayonara","adios"])
async def bye(self,ctx, user : discord.Member =None):
if not user:
user=ctx.author
await ctx.send('Bye! '+user.mention)
await ctx.send(random.choice(bye_urls))



def setup(bot):
bot.add_cog(Greetings(bot))
49 changes: 49 additions & 0 deletions cogs/events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import discord
from discord.ext import commands,tasks
import random
import requests
import json
import asyncio
import itertools


class Events(commands.Cog):
def __init__(self,bot):
self.bot=bot

@commands.Cog.listener()
async def on_member_join(self,member):
for channel in member.guild.channels:
if ('welcome' in channel.name.lower()):
try:
welcome=discord.Embed(title=member.name,description=f"""Welcome to {member.guild} {member.mention}""",color=discord.Colour.red())
welcome.add_field(name="ID",value=member.id,inline=False)
welcome.set_thumbnail(url=member.avatar_url)
await channel.send(embed=welcome)
except Exception as e:
pass

@commands.Cog.listener()
async def on_member_remove(self,member):
for channel in member.guild.channels:
if ('goodbye' in channel.name.lower()):
try:
left=discord.Embed(title=member.name,description=f"""{member.mention} left the server""",color=discord.Colour.red())
left.add_field(name="ID",value=member.id,inline=False)
left.set_thumbnail(url=member.avatar_url)
await channel.send(embed=left)
except Exception as e:
pass

@commands.Cog.listener()
async def on_command_error(self,ctx,error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("Please pass in all required arguments!")
elif isinstance(error,commands.CommandNotFound):
await ctx.send("Invalid command!")
elif isinstance(error,commands.MissingPermissions):
await ctx.send("You are not authorized to use this command!")


def setup(bot):
bot.add_cog(Events(bot))
23 changes: 23 additions & 0 deletions cogs/example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
##import discord
##from discord.ext import commands,tasks
##import random
##import requests
##import json
##import asyncio
##import itertools
##
##
##class Example(commands.Cog):
## def __init__(self,bot):
## self.bot=bot
##
## @commands.Cog.listener()
## async def on_ready(self):
## print('We have logged in as {0.user}'.format(self.bot))
##
## @commands.command()
## async def ping(self,ctx):
## await ctx.send(f'Pong! {round(self.bot.latency *1000)}ms')
##
##def setup(bot):
## bot.add_cog(Example(bot))
Loading

0 comments on commit d69a023

Please sign in to comment.