support mentions in /fm

This commit is contained in:
yuki 2025-10-08 21:05:32 -03:00
parent ba5442d854
commit 59763c308e

View file

@ -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)