diff options
Diffstat (limited to 'bot/exts/avatar_modification')
-rw-r--r-- | bot/exts/avatar_modification/_effects.py | 8 | ||||
-rw-r--r-- | bot/exts/avatar_modification/avatar_modify.py | 26 |
2 files changed, 18 insertions, 16 deletions
diff --git a/bot/exts/avatar_modification/_effects.py b/bot/exts/avatar_modification/_effects.py index f1c2e6d1..fcc62ebb 100644 --- a/bot/exts/avatar_modification/_effects.py +++ b/bot/exts/avatar_modification/_effects.py @@ -1,8 +1,8 @@ import math import random +from collections.abc import Callable from io import BytesIO from pathlib import Path -from typing import Callable, Optional import discord from PIL import Image, ImageDraw, ImageOps @@ -55,7 +55,7 @@ class PfpEffects: @staticmethod def crop_avatar_circle(avatar: Image.Image) -> Image.Image: - """This crops the avatar given into a circle.""" + """Crop the avatar given into a circle.""" mask = Image.new("L", avatar.size, 0) draw = ImageDraw.Draw(mask) draw.ellipse((0, 0) + avatar.size, fill=255) @@ -64,7 +64,7 @@ class PfpEffects: @staticmethod def crop_ring(ring: Image.Image, px: int) -> Image.Image: - """This crops the given ring into a circle.""" + """Crop the given ring into a circle.""" mask = Image.new("L", ring.size, 0) draw = ImageDraw.Draw(mask) draw.ellipse((0, 0) + ring.size, fill=255) @@ -108,7 +108,7 @@ class PfpEffects: return image @staticmethod - def easterify_effect(image: Image.Image, overlay_image: Optional[Image.Image] = None) -> Image.Image: + def easterify_effect(image: Image.Image, overlay_image: Image.Image | None = None) -> Image.Image: """ Applies the easter effect to the given image. diff --git a/bot/exts/avatar_modification/avatar_modify.py b/bot/exts/avatar_modification/avatar_modify.py index 6d1f26f6..4eae269f 100644 --- a/bot/exts/avatar_modification/avatar_modify.py +++ b/bot/exts/avatar_modification/avatar_modify.py @@ -4,9 +4,10 @@ import logging import math import string import unicodedata +from collections.abc import Callable from concurrent.futures import ThreadPoolExecutor from pathlib import Path -from typing import Callable, Optional, TypeVar, Union +from typing import TypeVar import discord from discord.ext import commands @@ -64,7 +65,7 @@ class AvatarModify(commands.Cog): def __init__(self, bot: Bot): self.bot = bot - async def _fetch_user(self, user_id: int) -> Optional[discord.User]: + async def _fetch_user(self, user_id: int) -> discord.User | None: """ Fetches a user and handles errors. @@ -120,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: Optional[str]) -> None: + async def reverse(self, ctx: commands.Context, *, text: str | None) -> None: """ Reverses the sent text. @@ -157,9 +158,9 @@ 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: Union[discord.Colour, str]) -> None: + async def avatareasterify(self, ctx: commands.Context, *colours: discord.Colour | str) -> None: """ - This "Easterifies" the user's avatar. + Easterify the user's avatar. Given colours will produce a personalised egg in the corner, similar to the egg_decorate command. If colours are not given, a nice little chocolate bunny will sit in the corner. @@ -168,13 +169,14 @@ class AvatarModify(commands.Cog): """ async def send(*args, **kwargs) -> str: """ - This replaces the original ctx.send. + Replace the original ctx.send. When invoking the egg decorating command, the egg itself doesn't print to to the channel. - Returns the message content so that if any errors occur, the error message can be output. + Return the message content so that if any errors occur, the error message can be output. """ if args: return args[0] + return None async with ctx.typing(): user = await self._fetch_user(ctx.author.id) @@ -248,11 +250,11 @@ class AvatarModify(commands.Cog): ) async def prideavatar(self, ctx: commands.Context, option: str = "lgbt", pixels: int = 64) -> None: """ - This surrounds an avatar with a border of a specified LGBT flag. + Surround an avatar with a border of a specified LGBT flag. - This defaults to the LGBT rainbow flag if none is given. + Default to the LGBT rainbow flag if none is given. The amount of pixels can be given which determines the thickness of the flag border. - This has a maximum of 512px and defaults to a 64px border. + A maximum of 512px is enforced, defaults to a 64px border. The full image is 1024x1024. """ option = option.lower() @@ -272,7 +274,7 @@ class AvatarModify(commands.Cog): @prideavatar.command() async def flags(self, ctx: commands.Context) -> None: - """This lists the flags that can be used with the prideavatar command.""" + """Lists the flags that can be used with the prideavatar command.""" choices = sorted(set(GENDER_OPTIONS.values())) options = "• " + "\n• ".join(choices) embed = discord.Embed( @@ -288,7 +290,7 @@ class AvatarModify(commands.Cog): brief="Spookify a user's avatar." ) async def spookyavatar(self, ctx: commands.Context) -> None: - """This "spookifies" the user's avatar, with a random *spooky* effect.""" + """Spookify the user's avatar, with a random *spooky* effect.""" user = await self._fetch_user(ctx.author.id) if not user: await ctx.send(f"{Emojis.cross_mark} Could not get user info.") |