support mentions in /fm
This commit is contained in:
parent
ba5442d854
commit
59763c308e
1 changed files with 17 additions and 6 deletions
|
|
@ -7,16 +7,27 @@ import utils as u
|
||||||
def setup(bot: bot.Bot):
|
def setup(bot: bot.Bot):
|
||||||
@bot.command(name="fm", aliases=["np"])
|
@bot.command(name="fm", aliases=["np"])
|
||||||
@bot.slash_command(name="fm", description="Shows what you're currently playing")
|
@bot.slash_command(name="fm", description="Shows what you're currently playing")
|
||||||
async def fm(ctx: nerimity.Context, lookup: str = None):
|
async def fm(ctx: nerimity.Context, username: str = None):
|
||||||
if lookup: username = lookup
|
if not username:
|
||||||
else:
|
|
||||||
try: username = await bot.get_lastfm(ctx.author.id)
|
try: username = await bot.get_lastfm(ctx.author.id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await ctx.send(u.error_msg(f"Unknown database error:\n{e}"))
|
await ctx.send(u.error_msg(f"Unknown database error:\n{e}"))
|
||||||
|
|
||||||
if not username:
|
if not username:
|
||||||
await ctx.send(u.error_msg("Please provide a Last.fm username (or set yours with `/setfm`)"))
|
await ctx.send(u.error_msg("Please provide a Last.fm username (or set yours with `/setfm`)"))
|
||||||
return
|
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:
|
try:
|
||||||
user = bot.lastfm.get_user(username)
|
user = bot.lastfm.get_user(username)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue