diff --git a/common.py b/common.py index 858e25a..e0270b3 100644 --- a/common.py +++ b/common.py @@ -15,11 +15,13 @@ from datetime import datetime from pathlib import Path from types import SimpleNamespace +from typing import Union import aiohttp import discord import discord.ext.commands as commands +from discord import Emoji, Reaction, PartialEmoji import data.options as opt @@ -158,7 +160,7 @@ async def convert(self, ctx: commands.Context, argument: str): def embed_factory(ctx: commands.Context) -> discord.Embed: """Creates an embed with neutral colour and standard footer.""" embed = discord.Embed(timestamp=datetime.utcnow(), colour=colours.neutral) - embed.set_footer(text=ctx.author, icon_url=str(ctx.author.avatar_url)) + embed.set_footer(text=str(ctx.author), icon_url=str(ctx.author.avatar_url)) return embed @@ -175,11 +177,12 @@ def error_embed_factory(ctx: commands.Context, exception: Exception, debug_mode: return embed -async def add_react(msg: discord.Message, react: str): +async def add_react(msg: discord.Message, react: Union[Emoji, Reaction, PartialEmoji, str]): try: await msg.add_reaction(react) except discord.Forbidden: - print(f"[!!] Missing permissions to add reaction in '{msg.guild.id}/{msg.channel.id}'!") + idpath = (f"{msg.guild.id}/" if msg.guild else "") + str(msg.channel.id) + print(f"[!!] Missing permissions to add reaction in '{idpath}'!") # --- Checks --- diff --git a/main.py b/main.py index 6344358..3aa95ca 100644 --- a/main.py +++ b/main.py @@ -100,7 +100,7 @@ async def _extctl(ctx: commands.Context): """Extension control commands. Defaults to `list` if no subcommand specified""" if ctx.invoked_subcommand is None: - cmd = bot.get_command("extctl list") + cmd = _extctl_list await ctx.invoke(cmd) @@ -168,7 +168,7 @@ async def on_command_error(ctx: commands.Context, err: commands.CommandError): await cmn.add_react(ctx.message, cmn.emojis.warning) await ctx.send_help(ctx.command) elif isinstance(err, commands.CommandNotFound): - if ctx.invoked_with.startswith(("?", "!")): + if ctx.invoked_with and ctx.invoked_with.startswith(("?", "!")): return else: await cmn.add_react(ctx.message, cmn.emojis.question)