diff options
author | 2023-05-06 16:12:32 +0100 | |
---|---|---|
committer | 2023-05-09 15:41:50 +0100 | |
commit | 613840ebcf303e84048d48ace37fb001c1afe687 (patch) | |
tree | 9acaf0bae0527fe8389483a419b44e06997ca060 /bot/exts/avatar_modification/avatar_modify.py | |
parent | Migrate to ruff (diff) |
Apply fixes for ruff linting
Co-authored-by: wookie184 <[email protected]>
Co-authored-by: Amrou Bellalouna <[email protected]>
Diffstat (limited to 'bot/exts/avatar_modification/avatar_modify.py')
-rw-r--r-- | bot/exts/avatar_modification/avatar_modify.py | 26 |
1 files changed, 14 insertions, 12 deletions
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.") |