mirror of https://github.com/sgoudham/Enso-Bot.git
Deleting previous cogs as they have been moved into fun.py
parent
31e114ac6c
commit
8699129049
@ -1,115 +0,0 @@
|
|||||||
import datetime
|
|
||||||
import random
|
|
||||||
import string
|
|
||||||
|
|
||||||
from aiohttp import request
|
|
||||||
from discord import Colour, Embed
|
|
||||||
from discord.ext import commands
|
|
||||||
from discord.ext.commands import BucketType, cooldown, command
|
|
||||||
|
|
||||||
from settings import colour_list
|
|
||||||
|
|
||||||
|
|
||||||
# Set up the cog
|
|
||||||
class Doggo(commands.Cog):
|
|
||||||
def __init__(self, bot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
@command(name="doggo", aliases=["Doggo"])
|
|
||||||
@cooldown(1, 1, BucketType.user)
|
|
||||||
async def doggo(self, ctx, breed=None):
|
|
||||||
"""Allows an API to grab images of dogs"""
|
|
||||||
|
|
||||||
# Set member as the author
|
|
||||||
member = ctx.message.author
|
|
||||||
# Get the member avatar
|
|
||||||
userAvatar = member.avatar_url
|
|
||||||
|
|
||||||
# Initialise array to store doggo pics
|
|
||||||
b_list = []
|
|
||||||
|
|
||||||
# If a breed if specified
|
|
||||||
if breed:
|
|
||||||
# Get the lowercase string input
|
|
||||||
lowercase_breed = breed.lower()
|
|
||||||
|
|
||||||
# If the user wants to know what breeds there are
|
|
||||||
if lowercase_breed == "breeds":
|
|
||||||
# Get the list of breeds
|
|
||||||
breed_url = "https://dog.ceo/api/breeds/list/all"
|
|
||||||
|
|
||||||
# Using API, retrieve the full list of breeds available
|
|
||||||
async with request("GET", breed_url, headers={}) as response:
|
|
||||||
if response.status == 200:
|
|
||||||
data = await response.json()
|
|
||||||
breed_link = data["message"]
|
|
||||||
|
|
||||||
# Store every Doggo in an array
|
|
||||||
for doggo in breed_link:
|
|
||||||
b_list.append(doggo)
|
|
||||||
|
|
||||||
# Join together all the breeds into a string
|
|
||||||
doggo_string = string.capwords(", ".join(b_list))
|
|
||||||
|
|
||||||
# Tell the user to try the breeds listed below
|
|
||||||
await ctx.send(f"Try the Breeds listed below!\n{doggo_string}")
|
|
||||||
|
|
||||||
# If no breed has been specified
|
|
||||||
else:
|
|
||||||
|
|
||||||
# Grab a random image of a doggo with the breed specified
|
|
||||||
image_url = f"https://dog.ceo/api/breed/{lowercase_breed}/images/random"
|
|
||||||
|
|
||||||
# Using API, retrieve the image of a doggo of the breed specified
|
|
||||||
async with request("GET", image_url, headers={}) as response:
|
|
||||||
if response.status == 200:
|
|
||||||
data = await response.json()
|
|
||||||
image_link = data["message"]
|
|
||||||
|
|
||||||
# Set up the embed for a doggo image
|
|
||||||
doggo_embed = Embed(
|
|
||||||
title=f"**It's a {lowercase_breed.capitalize()} Doggo!!** ",
|
|
||||||
colour=Colour(random.choice(colour_list)),
|
|
||||||
timestamp=datetime.datetime.utcnow())
|
|
||||||
doggo_embed.set_image(url=image_link)
|
|
||||||
doggo_embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
|
|
||||||
|
|
||||||
# Send the doggo image
|
|
||||||
await ctx.send(embed=doggo_embed)
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
# Send error message that Doggo was not found!
|
|
||||||
await ctx.send(
|
|
||||||
"Doggo Not Found! Please do **~doggo `breeds`** to see the full list of Doggos!")
|
|
||||||
else:
|
|
||||||
|
|
||||||
# Grab a random image of a doggo of any breed
|
|
||||||
image_url = "https://dog.ceo/api/breeds/image/random"
|
|
||||||
|
|
||||||
# Using API, retrieve the image of a doggo of any breed
|
|
||||||
async with request("GET", image_url, headers={}) as response:
|
|
||||||
if response.status == 200:
|
|
||||||
data = await response.json()
|
|
||||||
image_link = data["message"]
|
|
||||||
|
|
||||||
# Set up the embed for a random doggo image
|
|
||||||
doggo_embed = Embed(
|
|
||||||
title=f"**Doggo!** ",
|
|
||||||
colour=Colour(random.choice(colour_list)),
|
|
||||||
timestamp=datetime.datetime.utcnow())
|
|
||||||
doggo_embed.set_image(url=image_link)
|
|
||||||
doggo_embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
|
|
||||||
|
|
||||||
# Send random doggo image to the channel
|
|
||||||
await ctx.send(embed=doggo_embed)
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
# Send error message that Doggo was not found!
|
|
||||||
await ctx.send(
|
|
||||||
"Doggo Not Found! Please do **~doggo `breeds`** to see the full list of Doggos!")
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
bot.add_cog(Doggo(bot))
|
|
@ -1,40 +0,0 @@
|
|||||||
import urllib.parse
|
|
||||||
|
|
||||||
from aiohttp import request
|
|
||||||
from discord.ext import commands
|
|
||||||
from discord.ext.commands import BucketType, cooldown, command
|
|
||||||
|
|
||||||
|
|
||||||
# Set up the cog
|
|
||||||
class eightball(commands.Cog):
|
|
||||||
def __init__(self, bot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
@command(name="8ball", aliases=['8Ball'])
|
|
||||||
@cooldown(1, 1, BucketType.user)
|
|
||||||
async def _8ball(self, ctx, *, question):
|
|
||||||
"""8ball responses!"""
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Make the text readable to the api
|
|
||||||
eightball_question = urllib.parse.quote(question)
|
|
||||||
|
|
||||||
# Using API, make a connection to 8ball API
|
|
||||||
async with request("GET", f"https://8ball.delegator.com/magic/JSON/{eightball_question}",
|
|
||||||
headers={}) as response:
|
|
||||||
|
|
||||||
# With a successful connection
|
|
||||||
# Get the answer
|
|
||||||
if response.status == 200:
|
|
||||||
data = await response.json()
|
|
||||||
api_question = data["magic"]
|
|
||||||
api_answer = api_question["answer"]
|
|
||||||
|
|
||||||
await ctx.send(api_answer)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
bot.add_cog(eightball(bot))
|
|
@ -1,88 +0,0 @@
|
|||||||
import textwrap
|
|
||||||
|
|
||||||
import discord
|
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
|
||||||
from discord.ext import commands
|
|
||||||
from discord.ext.commands import command, cooldown, BucketType
|
|
||||||
|
|
||||||
|
|
||||||
def generate_meme(image_path, top_text, bottom_text='', font_path='homies/impact/Impacted.ttf', font_size=9):
|
|
||||||
get_image = Image.open(image_path)
|
|
||||||
draw = ImageDraw.Draw(get_image)
|
|
||||||
image_width, image_height = get_image.size
|
|
||||||
|
|
||||||
# Load font
|
|
||||||
font = ImageFont.truetype(font=font_path, size=int(image_height * font_size) // 100)
|
|
||||||
|
|
||||||
# Convert text to uppercase
|
|
||||||
top_text = top_text.upper()
|
|
||||||
bottom_text = bottom_text.upper()
|
|
||||||
|
|
||||||
# Text wrapping
|
|
||||||
char_width, char_height = font.getsize('A')
|
|
||||||
chars_per_line = image_width // char_width
|
|
||||||
top_lines = textwrap.wrap(top_text, width=chars_per_line)
|
|
||||||
bottom_lines = textwrap.wrap(bottom_text, width=chars_per_line)
|
|
||||||
|
|
||||||
# Draw top lines
|
|
||||||
y = 10
|
|
||||||
for line in top_lines:
|
|
||||||
line_width, line_height = font.getsize(line)
|
|
||||||
x = (image_width - line_width) / 2
|
|
||||||
draw.text((x, y), line, fill='white', font=font)
|
|
||||||
y += line_height
|
|
||||||
|
|
||||||
# Draw bottom lines
|
|
||||||
y = image_height - char_height * len(bottom_lines) - 15
|
|
||||||
for line in bottom_lines:
|
|
||||||
line_width, line_height = font.getsize(line)
|
|
||||||
x = (image_width - line_width) / 2
|
|
||||||
draw.text((x, y), line, fill='white', font=font)
|
|
||||||
y += line_height
|
|
||||||
|
|
||||||
# Save meme
|
|
||||||
get_image.save("AllMyHomiesHateMeme.jpg")
|
|
||||||
|
|
||||||
|
|
||||||
# Set up the cog
|
|
||||||
class Fun(commands.Cog):
|
|
||||||
def __init__(self, bot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
@command(name="homies", aliases=["Homies", "homie", "Homie"])
|
|
||||||
@cooldown(1, 10, BucketType.user)
|
|
||||||
async def homies(self, ctx, *, user_word):
|
|
||||||
"""Allows people to summon the homies"""
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Make sure the text entered is less than 20 characters
|
|
||||||
if len(user_word) >= 20:
|
|
||||||
await ctx.send("Please make sure the prompt is below **20** characters!")
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
|
|
||||||
# Define the text to be drawn on the top and the bottom
|
|
||||||
top_text = f"Ayo fuck {user_word}"
|
|
||||||
bottom_text = f"All my homies hate {user_word}"
|
|
||||||
|
|
||||||
# Call the method to generate the image
|
|
||||||
generate_meme('homies/AllMyHomies.jpg', top_text=top_text, bottom_text=bottom_text)
|
|
||||||
|
|
||||||
# Send the image file stored in the directory
|
|
||||||
await ctx.send(file=discord.File('AllMyHomiesHateMeme.jpg'))
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
bot.add_cog(Fun(bot))
|
|
||||||
|
|
||||||
|
|
||||||
""" # Set up the embed to display a random kissing gif
|
|
||||||
embed = Embed(
|
|
||||||
title=f"**The Homies**",
|
|
||||||
colour=Colour(int(random.choice(settings.colour_list))),
|
|
||||||
timestamp=datetime.datetime.utcnow())
|
|
||||||
embed.set_image(url=f"{image}")
|
|
||||||
embed.set_footer(text=f"Requested by {ctx.author}", icon_url='{}'.format(ctx.author.avatar_url))
|
|
||||||
"""
|
|
@ -1,30 +0,0 @@
|
|||||||
from discord.ext import commands
|
|
||||||
# OwO Impowt da wibwawy ÙωÙ
|
|
||||||
from discord.ext.commands import BucketType, cooldown, command
|
|
||||||
from owotext import OwO
|
|
||||||
|
|
||||||
|
|
||||||
# Initiate the cog
|
|
||||||
class OwOText(commands.Cog):
|
|
||||||
def __init__(self, bot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
# ~owo command allows for text to be 'converted to OWO'
|
|
||||||
@command(name="owo", aliases=["Owo", "OwO"])
|
|
||||||
@cooldown(1, 1, BucketType.user)
|
|
||||||
async def owo(self, ctx):
|
|
||||||
# Making sure that the string that gets converted is excluding the ~owo
|
|
||||||
if ctx.message.content.startswith(f"{ctx.prefix}owo"):
|
|
||||||
# Get the message to be converted
|
|
||||||
msg = ctx.message.content.split(f"{ctx.prefix}owo ", 1)
|
|
||||||
|
|
||||||
# Convert the message into owo text
|
|
||||||
uwu = OwO()
|
|
||||||
owo = uwu.whatsthis(str(msg[-1]))
|
|
||||||
|
|
||||||
# Send the owo version of the text to the channel
|
|
||||||
await ctx.message.channel.send(owo)
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
bot.add_cog(OwOText(bot))
|
|
@ -1,49 +0,0 @@
|
|||||||
import asyncio
|
|
||||||
|
|
||||||
from discord.ext import commands
|
|
||||||
from discord.ext.commands import command
|
|
||||||
|
|
||||||
|
|
||||||
# Set up the Cog
|
|
||||||
class Reminder(commands.Cog):
|
|
||||||
def __init__(self, bot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
# ~remindme command to allow the bot to dm you to remind you of something
|
|
||||||
@command(name="remindme", aliases=["Remindme", "rm"])
|
|
||||||
async def remind_me(self, ctx, time=None, *, text):
|
|
||||||
# Grab the author and store it in "author"
|
|
||||||
author = ctx.author
|
|
||||||
|
|
||||||
# If a value for time as been given
|
|
||||||
if time:
|
|
||||||
# Sleep the thread for the amount of time specified by the user
|
|
||||||
await asyncio.sleep(float(time))
|
|
||||||
# Send message to user's dms
|
|
||||||
await ctx.send(f"I've reminded you in your dms! {ctx.author.mention}")
|
|
||||||
await author.send(text)
|
|
||||||
|
|
||||||
# else no time has been given
|
|
||||||
else:
|
|
||||||
# Instantly Send message to user's dms
|
|
||||||
await author.send(text)
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
@commands.Cog.listener()
|
|
||||||
@commands.is.owner()
|
|
||||||
async def ():
|
|
||||||
time_left = [float(i) for i in str(datetime.now().time()).split(":")]
|
|
||||||
time_left = timedelta(hours=2) - timedelta(hours=time_left[0] % 2, minutes=time_left[1], seconds=time_left[2])
|
|
||||||
sleep(round(time_left.total_seconds()))
|
|
||||||
|
|
||||||
while True:
|
|
||||||
await ctx.send("Bump the Server Idiots")
|
|
||||||
sleep(7200)
|
|
||||||
|
|
||||||
_thread.start_new_thread(ex(self=self, ctx), ())
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
bot.add_cog(Reminder(bot))
|
|
Loading…
Reference in New Issue