diff --git a/payphone/cogs/mods/cog.py b/payphone/cogs/mods/cog.py index db9d2d6..b530dc2 100644 --- a/payphone/cogs/mods/cog.py +++ b/payphone/cogs/mods/cog.py @@ -403,8 +403,8 @@ class Mods(base.Cog): user_id = user - user = await models.User.get(id=user_id).prefetch_related("profiles") - profile: models.Profile = user.profiles[0] + user = await models.User.get_or_none(id=user_id).prefetch_related("profiles") + profile: models.Profile | None = user.profiles[0] if user is not None else None bans = await models.Ban.filter( expressions.Q( @@ -416,7 +416,7 @@ class Mods(base.Cog): ) embed = discord.Embed( - color=profile.color or constants.EMBED_COLOR, + color=(profile.color or constants.EMBED_COLOR) if profile is not None else constants.EMBED_COLOR, title="Profile Information", timestamp=datetime.now(timezone.utc), fields=[ @@ -431,8 +431,8 @@ class Mods(base.Cog): or "*No ongoing bans.*", ) ], - author=profile.embed_author, - thumbnail=profile.avatar_url + author=profile.embed_author if profile is not None else self.bot.embed_author, + thumbnail=profile.avatar_url if profile is not None else self.bot.user.display_avatar.url ) await ctx.send(embed=embed) diff --git a/payphone/core/converters.py b/payphone/core/converters.py index 6ac25fc..cf73d5d 100644 --- a/payphone/core/converters.py +++ b/payphone/core/converters.py @@ -44,10 +44,10 @@ class DiscordUserID(converter.Converter): """Converts a URL, ID, or reply into a Discord User ID.""" async def convert(self, ctx: commands.Context, argument: str) -> int: - if len(argument) > 17 and argument[:2] == "<@" and argument[-1] == ">": - return int(argument[2:-1]) + if len(argument) > 17 and argument[2:-1].isdecimal(): + return int() - if argument.isdecimal() and len(argument) in range(17, 19): + if argument.isdecimal() and len(argument) in range(17, 20): return int(argument) if argument.startswith("https://discord.com/users/") or argument.startswith(