Merge pull request #8 from Fluffy-Bean/deepsource-transform-76bdbef5

format code with black
This commit is contained in:
Michał Gdula 2023-09-09 12:29:05 +01:00 committed by GitHub
commit 60d1aaa13d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 10 deletions

View file

@ -27,7 +27,9 @@ class Animals(commands.Cog):
return
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:
response.seek(0)

View file

@ -16,7 +16,9 @@ class Img(commands.Cog):
self.bot = bot
@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()
overlay_choice = overlay_choice.lower().strip() if overlay_choice else None
@ -62,11 +64,12 @@ class Img(commands.Cog):
return
# 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:
error = (
"Unsupported file type! Supported file types are "
", ".join(IMAGE_EXTENSIONS)
error = "Unsupported file type! Supported file types are " ", ".join(
IMAGE_EXTENSIONS
)
await ctx.reply(embed=error_message(error))
return
@ -131,15 +134,21 @@ class Img(commands.Cog):
elif overlay_choice == "bandicam":
overlay = Image.open(IMAGE_OVERLAYS[overlay_choice]["path"])
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":
overlay = Image.open(IMAGE_OVERLAYS[overlay_choice]["path"])
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":
overlay = Image.open(IMAGE_OVERLAYS[overlay_choice]["path"])
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:
attachment.save(response, format="PNG")
@ -149,7 +158,10 @@ class Img(commands.Cog):
time_taken = (datetime.datetime.now() - start_time).microseconds / 1000
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_footer(text=f"{width}x{height}, {time_taken}ms")
)