From f45d91d0c0883ee2a0c285ed50c8ee7e81781429 Mon Sep 17 00:00:00 2001 From: yuki Date: Thu, 9 Oct 2025 03:54:33 -0300 Subject: [PATCH] create top artists command --- commands/top.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/commands/top.py b/commands/top.py index 19c80b8..4ef330f 100644 --- a/commands/top.py +++ b/commands/top.py @@ -58,14 +58,11 @@ def setup(bot: bot.Bot): top_list = user.get_top_artists(period=timeframe, limit=count, cacheable=False) for index, i in enumerate(top_list): msg_content += f"\n{index+1}. [{i.item.get_name(properly_capitalized=True)}]({i.item.get_url()}) | {i.weight} plays" - case "album": + + case "album" | "track": top_list = user.get_top_albums(period=timeframe, limit=count) for index, i in top_list: msg_content += f"\n{index+1}. [{i.item.get_title(properly_capitalized=True)}]({i.item.get_url()}) by [{i.item.get_artist().get_name(properly_capitalized=True)}]({i.item.get_artist().get_url()}) | {i.weight} plays" - case "track": - top_list = user.get_top_tracks(period=timeframe, limit=count, cacheable=False) - for index, i in top_list: - msg_content += f"\n{index+1}. [{i.item.get_title(properly_capitalized=True)}]({i.item.get_url()}) by [{i.item.get_artist().get_name(properly_capitalized=True)}]({i.item.get_artist().get_url()}) | {i.weight} plays" msg_head = f"Top {len(top_list)} {entity}s {period} for [{username}]({user.get_url()}):\n" @@ -83,3 +80,14 @@ def setup(bot: bot.Bot): print(e) await ctx.send(u.error_msg(f"Unknown error:\n`{e}`")) return + + @bot.command(name="topartists", aliases=["ta","topartist"]) + @bot.slash_command(name="topartists", description="Generate a list of your top artists.") + async def topartists(ctx: nerimity.Context, timeframe: str = "7day", username: str = None, countstr: str = "10"): + await send_top( + ctx = ctx, + entity = "artist", + timeframe = timeframe, + username = username, + countstr = countstr + )