feat(bot): ✨ Add p.user command.
This commit is contained in:
@@ -9,7 +9,7 @@ import discord
|
||||
from discord import errors
|
||||
from discord.ext import commands
|
||||
|
||||
from tortoise import transactions
|
||||
from tortoise import transactions, expressions
|
||||
|
||||
from payphone import bot
|
||||
from payphone.db import models, utils
|
||||
@@ -243,9 +243,7 @@ class Mods(base.Cog):
|
||||
- `[<reason>]`: The reason of the shutdown.
|
||||
"""
|
||||
|
||||
oncall_channel_ids = list(
|
||||
await redis.smembers(constants.CHANNELS_ONCALL_SET)
|
||||
)
|
||||
oncall_channel_ids = list(await redis.smembers(constants.CHANNELS_ONCALL_SET))
|
||||
searching_channel_ids = list(
|
||||
await redis.smembers(constants.CHANNELS_SEARCH_QUEUE)
|
||||
)
|
||||
@@ -272,9 +270,7 @@ class Mods(base.Cog):
|
||||
|
||||
await asyncio.sleep(seconds)
|
||||
|
||||
oncall_channel_ids = list(
|
||||
await redis.smembers(constants.CHANNELS_ONCALL_SET)
|
||||
)
|
||||
oncall_channel_ids = list(await redis.smembers(constants.CHANNELS_ONCALL_SET))
|
||||
searching_channel_ids = list(
|
||||
await redis.smembers(constants.CHANNELS_SEARCH_QUEUE)
|
||||
)
|
||||
@@ -396,6 +392,51 @@ class Mods(base.Cog):
|
||||
if i < iterations:
|
||||
await asyncio.sleep(wait)
|
||||
|
||||
@commands.command()
|
||||
async def user(self, ctx: commands.Context, user: converters.DiscordUserID) -> None:
|
||||
"""
|
||||
Shows all the information about a user.
|
||||
|
||||
Options:
|
||||
- `[<user>]`: The user, their ID, or `.` or `reply` replying to their message.
|
||||
"""
|
||||
|
||||
user_id = user
|
||||
|
||||
user = await models.User.get(id=user_id).prefetch_related("profiles")
|
||||
profile: models.Profile = user.profiles[0]
|
||||
|
||||
bans = await models.Ban.filter(
|
||||
expressions.Q(
|
||||
expires_at=None,
|
||||
expires_at__gt=datetime.now(timezone.utc),
|
||||
join_type="OR",
|
||||
),
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
embed = discord.Embed(
|
||||
color=profile.color or constants.EMBED_COLOR,
|
||||
title="Profile Information",
|
||||
timestamp=datetime.now(timezone.utc),
|
||||
fields=[
|
||||
discord.EmbedField(
|
||||
name="Ongoing Bans",
|
||||
value="\n".join(
|
||||
[
|
||||
f"- `ID: {ban.id}`{f" (by <@{ban.banned_by_id}>)" if ban.banned_by_id else None}: {ban.reason if ban.reason else "*No reason*"}. Banned {f"until <t:{int(ban.expires_at.timestamp())}:R>" if ban.expires_at is not None else "permanently"}."
|
||||
for ban in bans
|
||||
]
|
||||
)
|
||||
or "*No ongoing bans.*",
|
||||
)
|
||||
],
|
||||
author=profile.embed_author,
|
||||
thumbnail=profile.avatar_url
|
||||
)
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
|
||||
def setup(b: bot.Payphone) -> None:
|
||||
"""Load the cog into the bot.
|
||||
|
||||
Reference in New Issue
Block a user