aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-04-01 01:06:53 +0200
committerLinnea Gräf <nea@nea.moe>2025-04-01 01:06:53 +0200
commit916e8d32d00d5958ecd972c175c54667d4c62a15 (patch)
tree52935e2110ef8e330475d910614f18f61e2a0893
parenta3b870ddd622c6bf2a929d2800785448df6d4f59 (diff)
downloadadultnea-916e8d32d00d5958ecd972c175c54667d4c62a15.tar.gz
adultnea-916e8d32d00d5958ecd972c175c54667d4c62a15.tar.bz2
adultnea-916e8d32d00d5958ecd972c175c54667d4c62a15.zip
feat: Add basic user infoHEADmaster
-rw-r--r--adultnea/client.py12
-rw-r--r--adultnea/modules/info.py30
2 files changed, 33 insertions, 9 deletions
diff --git a/adultnea/client.py b/adultnea/client.py
index 26cdc92..78e6bc7 100644
--- a/adultnea/client.py
+++ b/adultnea/client.py
@@ -20,11 +20,19 @@ class Context(commands.Context['AdultClient']):
self,
content: str,
attachments: Sequence[discord.File] = discord.utils.MISSING,
+ allowed_mentions: Optional[discord.AllowedMentions] = None,
):
+ allowed_mentions = allowed_mentions or discord.AllowedMentions.none()
if self.followup_message:
- await self.followup_message.edit(content=content, attachments=attachments)
+ await self.followup_message.edit(
+ content=content,
+ attachments=attachments,
+ allowed_mentions=allowed_mentions,
+ )
else:
- self.followup_message = await self.reply(content, files=attachments)
+ self.followup_message = await self.reply(
+ content, files=attachments, allowed_mentions=allowed_mentions
+ )
class AdultClient(commands.Bot):
diff --git a/adultnea/modules/info.py b/adultnea/modules/info.py
index 53f212e..c89d3a8 100644
--- a/adultnea/modules/info.py
+++ b/adultnea/modules/info.py
@@ -1,12 +1,21 @@
import datetime
import textwrap
import typing
+from typing import TypeAlias
import discord.ext.commands as commands
import discord
from adultnea.client import AdultClient, Context
+GenericGuild: TypeAlias = typing.Union[discord.abc.GuildChannel, discord.Guild]
+
+
+def ungeneric_guild(generic: GenericGuild) -> discord.Guild:
+ if isinstance(generic, discord.abc.GuildChannel):
+ return generic.guild
+ return generic
+
@commands.group()
async def dinfo(ctx: Context):
@@ -14,8 +23,18 @@ async def dinfo(ctx: Context):
@dinfo.command(aliases=['u'])
-async def user(ctx: Context, user: discord.User):
- pass # TODO
+async def user(ctx: Context, user: discord.User, guild: typing.Optional[GenericGuild]):
+ info = textwrap.dedent(
+ f"""
+ **User**: {user.name} {user.mention}
+ **Created At**: {format_timestamp(user.created_at)}
+ """
+ )
+ await ctx.followup(info)
+ # if guild:
+ # guild = ungeneric_guild(guild)
+ # member = await guild.fetch_member(user.id)
+ # TODO: do something with this info
def format_timestamp(i: datetime.datetime):
@@ -23,11 +42,8 @@ def format_timestamp(i: datetime.datetime):
@dinfo.command(name='guild', aliases=['server', 's', 'g'])
-async def _guild(
- ctx: Context, guild: typing.Union[discord.abc.GuildChannel, discord.Guild]
-):
- if isinstance(guild, discord.abc.GuildChannel):
- guild = guild.guild
+async def _guild(ctx: Context, guild: GenericGuild):
+ guild = ungeneric_guild(guild)
guild = await ctx.bot.fetch_guild(guild.id)
await ctx.followup(
textwrap.dedent(