Skip to content

Commit b5416d9

Browse files
Merge pull request #13 from ThePrivatePanda/toolifelesstocode/feat/add-user-bolb-show
feat: allow users to view other's bolb count
2 parents f509cc2 + ecde3e8 commit b5416d9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

bolb_bot/cogs/bolbs.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from datetime import datetime, timedelta, timezone
44
from random import choices, randint
5-
from typing import TYPE_CHECKING
5+
from typing import TYPE_CHECKING, Optional
66

77
from nextcord import Embed, Member, AllowedMentions
88
from nextcord.ext.commands import Cog, Context, command
@@ -19,17 +19,23 @@ def __init__(self, bot: MyBot):
1919
self.bot = bot
2020

2121
@command(description="Show your Bolb stats.", aliases=["bolb_amt", "bolbs"])
22-
async def bolb(self, ctx: Context):
22+
async def bolb(self, ctx: Context, user: Optional[Member] = None):
23+
if not user:
24+
user = ctx.author
2325
async with self.bot.db.execute(
24-
"SELECT bolbs FROM bolb WHERE id=?", (ctx.author.id,)
26+
"SELECT bolbs FROM bolb WHERE id=?", (user.id,)
2527
) as c:
2628
row = await c.fetchone()
2729
amount = row[0] if row and row[0] else None
2830

2931
if not amount:
30-
await ctx.reply("You have no bolbs. Imagine")
32+
await ctx.reply(
33+
"You have" if not user else f"{user} has" " no bolbs. Imagine"
34+
)
3135
else:
32-
await ctx.reply(f"You have {amount} bolbs")
36+
await ctx.reply(
37+
f"You have" if not user else f"{user} has" f" {amount} bolbs"
38+
)
3339

3440
@command(description="Claim your daily bolbs", aliases=["dailyclaim"])
3541
async def daily(self, ctx: Context):

0 commit comments

Comments
 (0)