aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/avatar_modification
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts/evergreen/avatar_modification')
-rw-r--r--bot/exts/evergreen/avatar_modification/_effects.py12
-rw-r--r--bot/exts/evergreen/avatar_modification/avatar_modify.py12
2 files changed, 12 insertions, 12 deletions
diff --git a/bot/exts/evergreen/avatar_modification/_effects.py b/bot/exts/evergreen/avatar_modification/_effects.py
index 92244207..df741973 100644
--- a/bot/exts/evergreen/avatar_modification/_effects.py
+++ b/bot/exts/evergreen/avatar_modification/_effects.py
@@ -1,8 +1,8 @@
import math
import random
-import typing as t
from io import BytesIO
from pathlib import Path
+from typing import Callable, Optional
import discord
from PIL import Image, ImageDraw, ImageOps
@@ -18,7 +18,7 @@ class PfpEffects:
"""
@staticmethod
- def apply_effect(image_bytes: bytes, effect: t.Callable, filename: str, *args) -> discord.File:
+ def apply_effect(image_bytes: bytes, effect: Callable, filename: str, *args) -> discord.File:
"""Applies the given effect to the image passed to it."""
im = Image.open(BytesIO(image_bytes))
im = im.convert("RGBA")
@@ -32,7 +32,7 @@ class PfpEffects:
return discord.File(bufferedio, filename=filename)
@staticmethod
- def closest(x: t.Tuple[int, int, int]) -> t.Tuple[int, int, int]:
+ def closest(x: tuple[int, int, int]) -> tuple[int, int, int]:
"""
Finds the closest "easter" colour to a given pixel.
@@ -40,7 +40,7 @@ class PfpEffects:
"""
r1, g1, b1 = x
- def distance(point: t.Tuple[int, int, int]) -> t.Tuple[int, int, int]:
+ def distance(point: tuple[int, int, int]) -> int:
"""Finds the difference between a pastel colour and the original pixel colour."""
r2, g2, b2 = point
return (r1 - r2) ** 2 + (g1 - g2) ** 2 + (b1 - b2) ** 2
@@ -108,7 +108,7 @@ class PfpEffects:
return image
@staticmethod
- def easterify_effect(image: Image.Image, overlay_image: t.Optional[Image.Image] = None) -> Image.Image:
+ def easterify_effect(image: Image.Image, overlay_image: Optional[Image.Image] = None) -> Image.Image:
"""
Applies the easter effect to the given image.
@@ -212,7 +212,7 @@ class PfpEffects:
return new_imgs
@staticmethod
- def join_images(images: t.List[Image.Image]) -> Image.Image:
+ def join_images(images: list[Image.Image]) -> Image.Image:
"""
Stitches all the image squares into a new image.
diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py
index fd586613..2be09be2 100644
--- a/bot/exts/evergreen/avatar_modification/avatar_modify.py
+++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py
@@ -3,10 +3,10 @@ import json
import logging
import math
import string
-import typing as t
import unicodedata
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
+from typing import Callable, Optional, TypeVar, Union
import discord
from discord.ext import commands
@@ -25,12 +25,12 @@ FILENAME_STRING = "{effect}_{author}.png"
MAX_SQUARES = 10_000
-T = t.TypeVar("T")
+T = TypeVar("T")
GENDER_OPTIONS = json.loads(Path("bot/resources/pride/gender_options.json").read_text("utf8"))
-async def in_executor(func: t.Callable[..., T], *args) -> T:
+async def in_executor(func: Callable[..., T], *args) -> T:
"""
Runs the given synchronous function `func` in an executor.
@@ -65,7 +65,7 @@ class AvatarModify(commands.Cog):
def __init__(self, bot: Bot) -> None:
self.bot = bot
- async def _fetch_user(self, user_id: int) -> t.Optional[discord.User]:
+ async def _fetch_user(self, user_id: int) -> Optional[discord.User]:
"""
Fetches a user and handles errors.
@@ -121,7 +121,7 @@ class AvatarModify(commands.Cog):
await ctx.send(embed=embed, file=file)
@avatar_modify.command(name="reverse", root_aliases=("reverse",))
- async def reverse(self, ctx: commands.Context, *, text: t.Optional[str]) -> None:
+ async def reverse(self, ctx: commands.Context, *, text: Optional[str]) -> None:
"""
Reverses the sent text.
@@ -158,7 +158,7 @@ class AvatarModify(commands.Cog):
await ctx.send(embed=embed, file=file)
@avatar_modify.command(aliases=("easterify",), root_aliases=("easterify", "avatareasterify"))
- async def avatareasterify(self, ctx: commands.Context, *colours: t.Union[discord.Colour, str]) -> None:
+ async def avatareasterify(self, ctx: commands.Context, *colours: Union[discord.Colour, str]) -> None:
"""
This "Easterifies" the user's avatar.