From 59763c308ec70cef22d9e148159c896f1036309f Mon Sep 17 00:00:00 2001 From: yuki Date: Wed, 8 Oct 2025 21:05:32 -0300 Subject: [PATCH] support mentions in /fm --- commands/now_playing.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/commands/now_playing.py b/commands/now_playing.py index b09301d..7e23a91 100644 --- a/commands/now_playing.py +++ b/commands/now_playing.py @@ -7,16 +7,27 @@ import utils as u def setup(bot: bot.Bot): @bot.command(name="fm", aliases=["np"]) @bot.slash_command(name="fm", description="Shows what you're currently playing") - async def fm(ctx: nerimity.Context, lookup: str = None): - if lookup: username = lookup - else: + async def fm(ctx: nerimity.Context, username: str = None): + if not username: try: username = await bot.get_lastfm(ctx.author.id) except Exception as e: await ctx.send(u.error_msg(f"Unknown database error:\n{e}")) - if not username: - await ctx.send(u.error_msg("Please provide a Last.fm username (or set yours with `/setfm`)")) - return + if not username: + await ctx.send(u.error_msg("Please provide a Last.fm username (or set yours with `/setfm`)")) + return + + if username.startswith("[@:"): + mentioned = bot.get_user(username[3:-1]) + try: username = await bot.get_lastfm(mentioned.id) + except Exception as e: + print(e) + await ctx.send(u.error_msg(f"Unknown database error:\n{e}")) + + if not username: + await ctx.send(u.error_msg(f"[@:{mentioned.id}] doesn't seem to have an account set. Do so with `/setfm`.")) + print("returned") + return try: user = bot.lastfm.get_user(username)