Added a grayscale image converter

Added alias for owo command (uwu is now the same thing as owo)
pull/8/head
sgoudham 4 years ago
parent e526d11dd4
commit 4eb9b5816a

@ -23,7 +23,6 @@ import urllib.parse
from typing import Optional from typing import Optional
import discord import discord
import pytesseract.pytesseract
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
from aiohttp import request from aiohttp import request
from discord import Member, Embed from discord import Member, Embed
@ -362,7 +361,7 @@ class Fun(Cog):
# Send the bytes object as an image file # Send the bytes object as an image file
await ctx.send(file=discord.File(file, "homies.png")) await ctx.send(file=discord.File(file, "homies.png"))
@command(name="owo") @command(name="owo", aliases=["uwu"])
@cooldown(1, 1, BucketType.user) @cooldown(1, 1, BucketType.user)
@bot_has_permissions(manage_messages=True) @bot_has_permissions(manage_messages=True)
async def owo(self, ctx, *, text): async def owo(self, ctx, *, text):
@ -378,22 +377,24 @@ class Fun(Cog):
# Send the text back # Send the text back
await ctx.message.channel.send(owo) await ctx.message.channel.send(owo)
@command(name="text", hidden=True) @command(name="grayscale", aliases=["gs"])
@cooldown(1, 1, BucketType.user) @cooldown(1, 5, BucketType.user)
@bot_has_permissions(attach_files=True)
async def image_to_text(self, ctx): async def image_to_text(self, ctx):
"""Display text from an image submitted""" """Display grayscale version of image uploaded"""
pytesseract.pytesseract.tesseract_cmd = r'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'
if ctx.message.attachments: if ctx.message.attachments:
for attachments in ctx.message.attachments: for attachments in ctx.message.attachments:
attach = await attachments.read() attach = await attachments.read()
image = Image.open(io.BytesIO(attach)).convert('LA')
image = Image.open(io.BytesIO(attach)) # Save new grayscale image as bytes
text = pytesseract.image_to_string(image) file = io.BytesIO()
image.save(file, format='PNG')
await ctx.send(text) file.seek(0)
# Send Grayscale Image
await ctx.send(file=discord.File(file, "gp.png"))
else: else:
await self.bot.generate_embed(ctx, desc="**Image Not Detected!**") await self.bot.generate_embed(ctx, desc="**Image Not Detected!**")

@ -202,9 +202,9 @@ class Info(Cog):
("Creation At", role.created_at.strftime("%a, %b %d, %Y\n%I:%M:%S %p"), True), ("Creation At", role.created_at.strftime("%a, %b %d, %Y\n%I:%M:%S %p"), True),
(f"Misc", (f"Misc",
f"\n Mentionable?: {mentionable}" + f"\nMentionable?: {mentionable}" +
f"\n Hoisted?: {hoisted}" + f"\nHoisted?: {hoisted}" +
f"\n Managed?: {managed}", True), f"\nManaged?: {managed}", True),
(f"Members ({len(role.members)})", (f"Members ({len(role.members)})",
f"\nHumans: {len(list(filter(lambda m: not m.bot, role.members)))}" + f"\nHumans: {len(list(filter(lambda m: not m.bot, role.members)))}" +

Loading…
Cancel
Save