diff --git a/canary/cogs/helpers.py b/canary/cogs/helpers.py index b7acf7a4..501873e4 100644 --- a/canary/cogs/helpers.py +++ b/canary/cogs/helpers.py @@ -35,7 +35,8 @@ import math import random import re -import time + +from typing import Optional from .base_cog import CanaryCog from .utils.arg_converter import ArgConverter, StrConverter @@ -408,7 +409,7 @@ async def lmgtfy(self, ctx: commands.Context, *, query: str): await ctx.send(url) @commands.command() - async def tex(self, ctx: commands.Context, *, query: str): + async def tex(self, ctx: commands.Context): """Parses and prints LaTeX equations.""" await ctx.trigger_typing() @@ -526,7 +527,7 @@ async def modpow(self, ctx: commands.Context, a, b, m): """Calculates a^b mod m, where a, b, c are big integers""" try: a, b, m = map(int, (a, b, m)) - await ctx.send(pow(a, b, m)) + await ctx.send(str(pow(a, b, m))) except ValueError: await ctx.send("Input must be integers") @@ -598,14 +599,18 @@ async def colour(self, ctx: commands.Context, *, arg: str): await ctx.send(file=discord.File(fp=buffer, filename=fn)) @commands.command(aliases=["ui", "av", "avi", "userinfo"]) - async def user_info(self, ctx: commands.Context, user: discord.Member | None = None): + async def user_info(self, ctx: commands.Context, user: Optional[discord.Member] = None): """ Show user info and avatar. Displays the information of the user that called the command, or another member's if one is passed as an optional argument.""" + + await ctx.trigger_typing() + if user is None: user = ctx.author + ui_embed = discord.Embed(colour=(user.id - sum(ord(char) for char in user.name)) % 0xFFFFFF) ui_embed.add_field(name="username", value=str(user)) ui_embed.add_field(name="display name", value=user.display_name) @@ -623,7 +628,7 @@ async def user_info(self, ctx: commands.Context, user: discord.Member | None = N await ctx.send(embed=ui_embed) @commands.command(aliases=["trans"]) - async def translate(self, ctx: commands.Context, command: str, *, inp_str: str | None = None): + async def translate(self, ctx: commands.Context, command: str, *, inp_str: Optional[str] = None): """ Command used to translate some text from one language to another Takes two arguments: the source/target languages and the text to translate @@ -638,6 +643,9 @@ async def translate(self, ctx: commands.Context, command: str, *, inp_str: str | taken from the message to which the invoking message was replying to, or if the invoking message is not a reply, then to the rest of the message after the first argument. """ + + await ctx.trigger_typing() + if command == "help": await ctx.send( "Command used to translate text.\n" @@ -725,7 +733,7 @@ async def create_main_webhooks(self, ctx: commands.Context): await ctx.send("Job completed.") async def spoilerize_utility( - self, ctx: commands.Context, message: discord.Message, reason: str | None = None, moderator: bool = False + self, ctx: commands.Context, message: discord.Message, reason: Optional[str] = None, moderator: bool = False ) -> None: db: aiosqlite.Connection diff --git a/canary/cogs/info.py b/canary/cogs/info.py index 71af932d..2d052e6d 100644 --- a/canary/cogs/info.py +++ b/canary/cogs/info.py @@ -22,7 +22,7 @@ class Info(CanaryCog): @commands.command() - async def version(self, ctx): + async def version(self, ctx: commands.Context): # TODO: use asyncio.create_subprocess_shell version = subprocess.check_output(("git", "describe", "--tags"), universal_newlines=True).strip() commit, authored = ( diff --git a/canary/cogs/mod.py b/canary/cogs/mod.py index dfd0a012..9c95e261 100644 --- a/canary/cogs/mod.py +++ b/canary/cogs/mod.py @@ -17,14 +17,16 @@ import discord import random + from bidict import bidict +from datetime import datetime, timedelta from discord import utils from discord.ext import commands, tasks +from typing import Optional from ..bot import Canary from .base_cog import CanaryCog from .utils.checks import is_moderator -from datetime import datetime, timedelta from .utils.role_restoration import ( save_existing_roles, fetch_saved_roles, @@ -216,7 +218,7 @@ async def verification_purge_utility(self, after: datetime | discord.Message | N @commands.command() @is_moderator() - async def verification_purge(self, ctx: commands.Context, id_: int | None = None): + async def verification_purge(self, ctx: commands.Context, id_: Optional[int] = None): """ Manually start the purge of pictures in the verification channel. diff --git a/canary/cogs/quotes.py b/canary/cogs/quotes.py index 53e402bd..abf06c12 100644 --- a/canary/cogs/quotes.py +++ b/canary/cogs/quotes.py @@ -367,7 +367,7 @@ async def all_quotes(self, ctx: commands.Context, *, query: Optional[str] = None await p.paginate() @commands.command(aliases=["gen"]) - async def generate(self, ctx: commands.Context, seed: str | None = None, min_length: int = 1): + async def generate(self, ctx: commands.Context, seed: Optional[str] = None, min_length: int = 1): """ Generates a random 'quote' using a Markov Chain. Optionally takes in a word to seed the Markov Chain with and (also optionally) a desired