Add message count to member card. Closes #12
This commit is contained in:
parent
f067485e88
commit
16173e428b
@ -60,8 +60,7 @@ class CommandContext:
|
||||
system = await self.get_system()
|
||||
|
||||
if not system:
|
||||
raise CommandError(
|
||||
embeds.error("No system registered to this account. Use `pk;system new` to register one."))
|
||||
raise CommandError("No system registered to this account. Use `pk;system new` to register one.")
|
||||
|
||||
return system
|
||||
|
||||
|
@ -152,6 +152,10 @@ async def generate_member_info_card(conn, member: Member) -> discord.Embed:
|
||||
if member.pronouns:
|
||||
card.add_field(name="Pronouns", value=member.pronouns)
|
||||
|
||||
message_count = await db.get_member_message_count(conn, member.id)
|
||||
if message_count > 0:
|
||||
card.add_field(name="Message Count", value=str(message_count), inline=True)
|
||||
|
||||
if member.prefix or member.suffix:
|
||||
prefix = member.prefix or ""
|
||||
suffix = member.suffix or ""
|
||||
@ -162,6 +166,5 @@ async def generate_member_info_card(conn, member: Member) -> discord.Embed:
|
||||
card.add_field(name="Description",
|
||||
value=member.description, inline=False)
|
||||
|
||||
card.set_footer(text="System ID: {} | Member ID: {}".format(
|
||||
system.hid, member.hid))
|
||||
card.set_footer(text="System ID: {} | Member ID: {}".format(system.hid, member.hid))
|
||||
return card
|
@ -259,6 +259,10 @@ async def delete_message(conn, message_id: str):
|
||||
logger.debug("Deleting message (id={})".format(message_id))
|
||||
await conn.execute("delete from messages where mid = $1", int(message_id))
|
||||
|
||||
@db_wrap
|
||||
async def get_member_message_count(conn, member_id: int) -> int:
|
||||
return await conn.fetchval("select count(*) from messages where member = $1", member_id)
|
||||
|
||||
@db_wrap
|
||||
async def front_history(conn, system_id: int, count: int):
|
||||
return await conn.fetch("""select
|
||||
|
Loading…
Reference in New Issue
Block a user