mirror of
https://github.com/Fluffy-Bean/Lynxie.git
synced 2025-05-14 08:02:17 +00:00
Merge pull request #8 from Fluffy-Bean/deepsource-transform-76bdbef5
format code with black
This commit is contained in:
commit
60d1aaa13d
2 changed files with 24 additions and 10 deletions
|
@ -27,7 +27,9 @@ class Animals(commands.Cog):
|
||||||
return
|
return
|
||||||
|
|
||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
request = requests.get("https://api.tinyfox.dev/img?animal=" + animal_choice)
|
request = requests.get(
|
||||||
|
"https://api.tinyfox.dev/img?animal=" + animal_choice
|
||||||
|
)
|
||||||
|
|
||||||
with BytesIO(request.content) as response:
|
with BytesIO(request.content) as response:
|
||||||
response.seek(0)
|
response.seek(0)
|
||||||
|
|
|
@ -16,7 +16,9 @@ class Img(commands.Cog):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def overlay(self, ctx, overlay_choice: str = None, overlay_style: str = "default"):
|
async def overlay(
|
||||||
|
self, ctx, overlay_choice: str = None, overlay_style: str = "default"
|
||||||
|
):
|
||||||
start_time = datetime.datetime.now()
|
start_time = datetime.datetime.now()
|
||||||
|
|
||||||
overlay_choice = overlay_choice.lower().strip() if overlay_choice else None
|
overlay_choice = overlay_choice.lower().strip() if overlay_choice else None
|
||||||
|
@ -62,11 +64,12 @@ class Img(commands.Cog):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Defaults to gwa as I cant be asked to make a better error handler
|
# Defaults to gwa as I cant be asked to make a better error handler
|
||||||
filename = image_attachments.filename or image_attachments.url or "image.gwa"
|
filename = (
|
||||||
|
image_attachments.filename or image_attachments.url or "image.gwa"
|
||||||
|
)
|
||||||
if not filename.split(".")[-1].lower() in IMAGE_EXTENSIONS:
|
if not filename.split(".")[-1].lower() in IMAGE_EXTENSIONS:
|
||||||
error = (
|
error = "Unsupported file type! Supported file types are " ", ".join(
|
||||||
"Unsupported file type! Supported file types are "
|
IMAGE_EXTENSIONS
|
||||||
", ".join(IMAGE_EXTENSIONS)
|
|
||||||
)
|
)
|
||||||
await ctx.reply(embed=error_message(error))
|
await ctx.reply(embed=error_message(error))
|
||||||
return
|
return
|
||||||
|
@ -131,15 +134,21 @@ class Img(commands.Cog):
|
||||||
elif overlay_choice == "bandicam":
|
elif overlay_choice == "bandicam":
|
||||||
overlay = Image.open(IMAGE_OVERLAYS[overlay_choice]["path"])
|
overlay = Image.open(IMAGE_OVERLAYS[overlay_choice]["path"])
|
||||||
overlay.thumbnail((width, overlay.height))
|
overlay.thumbnail((width, overlay.height))
|
||||||
attachment.paste(overlay, ((width-overlay.width)//2, 0), overlay)
|
attachment.paste(overlay, ((width - overlay.width) // 2, 0), overlay)
|
||||||
elif overlay_choice == "jerma":
|
elif overlay_choice == "jerma":
|
||||||
overlay = Image.open(IMAGE_OVERLAYS[overlay_choice]["path"])
|
overlay = Image.open(IMAGE_OVERLAYS[overlay_choice]["path"])
|
||||||
overlay.thumbnail((width, overlay.height))
|
overlay.thumbnail((width, overlay.height))
|
||||||
attachment.paste(overlay, (width-overlay.width, height-overlay.height), overlay)
|
attachment.paste(
|
||||||
|
overlay, (width - overlay.width, height - overlay.height), overlay
|
||||||
|
)
|
||||||
elif overlay_choice == "jerm-a":
|
elif overlay_choice == "jerm-a":
|
||||||
overlay = Image.open(IMAGE_OVERLAYS[overlay_choice]["path"])
|
overlay = Image.open(IMAGE_OVERLAYS[overlay_choice]["path"])
|
||||||
overlay.thumbnail((width, overlay.height))
|
overlay.thumbnail((width, overlay.height))
|
||||||
attachment.paste(overlay, ((width-overlay.width)//2, height-overlay.height), overlay)
|
attachment.paste(
|
||||||
|
overlay,
|
||||||
|
((width - overlay.width) // 2, height - overlay.height),
|
||||||
|
overlay,
|
||||||
|
)
|
||||||
with BytesIO() as response:
|
with BytesIO() as response:
|
||||||
attachment.save(response, format="PNG")
|
attachment.save(response, format="PNG")
|
||||||
|
|
||||||
|
@ -149,7 +158,10 @@ class Img(commands.Cog):
|
||||||
time_taken = (datetime.datetime.now() - start_time).microseconds / 1000
|
time_taken = (datetime.datetime.now() - start_time).microseconds / 1000
|
||||||
|
|
||||||
embed = (
|
embed = (
|
||||||
discord.Embed(title=overlay_choice.capitalize(), colour=discord.Colour.orange())
|
discord.Embed(
|
||||||
|
title=overlay_choice.capitalize(),
|
||||||
|
colour=discord.Colour.orange(),
|
||||||
|
)
|
||||||
.set_image(url="attachment://image.png")
|
.set_image(url="attachment://image.png")
|
||||||
.set_footer(text=f"{width}x{height}, {time_taken}ms")
|
.set_footer(text=f"{width}x{height}, {time_taken}ms")
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue