fix(bot): 🐛 p.user not working on unregistered users.
This commit is contained in:
@@ -403,8 +403,8 @@ class Mods(base.Cog):
|
|||||||
|
|
||||||
user_id = user
|
user_id = user
|
||||||
|
|
||||||
user = await models.User.get(id=user_id).prefetch_related("profiles")
|
user = await models.User.get_or_none(id=user_id).prefetch_related("profiles")
|
||||||
profile: models.Profile = user.profiles[0]
|
profile: models.Profile | None = user.profiles[0] if user is not None else None
|
||||||
|
|
||||||
bans = await models.Ban.filter(
|
bans = await models.Ban.filter(
|
||||||
expressions.Q(
|
expressions.Q(
|
||||||
@@ -416,7 +416,7 @@ class Mods(base.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
embed = discord.Embed(
|
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",
|
title="Profile Information",
|
||||||
timestamp=datetime.now(timezone.utc),
|
timestamp=datetime.now(timezone.utc),
|
||||||
fields=[
|
fields=[
|
||||||
@@ -431,8 +431,8 @@ class Mods(base.Cog):
|
|||||||
or "*No ongoing bans.*",
|
or "*No ongoing bans.*",
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
author=profile.embed_author,
|
author=profile.embed_author if profile is not None else self.bot.embed_author,
|
||||||
thumbnail=profile.avatar_url
|
thumbnail=profile.avatar_url if profile is not None else self.bot.user.display_avatar.url
|
||||||
)
|
)
|
||||||
|
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ class DiscordUserID(converter.Converter):
|
|||||||
"""Converts a URL, ID, or reply into a Discord User ID."""
|
"""Converts a URL, ID, or reply into a Discord User ID."""
|
||||||
|
|
||||||
async def convert(self, ctx: commands.Context, argument: str) -> int:
|
async def convert(self, ctx: commands.Context, argument: str) -> int:
|
||||||
if len(argument) > 17 and argument[:2] == "<@" and argument[-1] == ">":
|
if len(argument) > 17 and argument[2:-1].isdecimal():
|
||||||
return int(argument[2:-1])
|
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)
|
return int(argument)
|
||||||
|
|
||||||
if argument.startswith("https://discord.com/users/") or argument.startswith(
|
if argument.startswith("https://discord.com/users/") or argument.startswith(
|
||||||
|
|||||||
Reference in New Issue
Block a user