def get_beatmap_embed(bmp: osu.Beatmap): beatmapEmbed = Embed( title=f'{bmp["title"]} [{bmp["version"]}] | {float(bmp["difficultyrating"]):.2f}★', url=osu.beatmap_link(bmp['beatmap_id']), color=EMBED_COLOR, ) beatmapEmbed.add_field( name=f'Beatmap Info ({bmp["beatmap_id"]}) ({osu.BEATMAP_STATUS_ENUM[int(bmp["approved"])]})', value=( f'Length **{format_seconds(int(bmp["total_length"]))}** ~ ' f'Max Combo **{bmp["max_combo"]}**\n' f'CS**{bmp["diff_size"]}** ' f'AR**{bmp["diff_approach"]}** ' f'OD**{bmp["diff_overall"]}** ' f'HP**{bmp["diff_drain"]}** ~ ' f'**{bmp["bpm"]}** BPM ~ ' f'**{float(bmp["difficultyrating"]):.2f}**★' ), inline=False ) beatmapEmbed.set_thumbnail(url=osu.beatmap_thumb(bmp['beatmapset_id'])) beatmapEmbed.set_footer( text=f'Mapped by {bmp["creator"]}', icon_url=osu.profile_thumb(bmp['creator_id']) ) return beatmapEmbed
async def osu_toprange(ctx: Context, rankstart: int = 1, rankend: int = 10, *, u: Optional[str] = None): if rankstart < 1 or rankend < 1 or rankend > 100 or rankstart > rankend or rankend - rankstart >= 30: return await ctx.send('invalid score rank range (max 30 scores, ranks must be between 1-100) ') if not u: u = get_osuid(ctx) if not u: return await ctx.send('invalid user') topScores = get_top_scores(u, rankend) if not topScores: return await ctx.send(f'No top scores found for user {u}. Make sure to provide a valid osu username/id.') scores = topScores[rankstart - 1: rankend] chunkedScores = chunk(scores, 10) user = get_user(u) first = True for scoreChunk in chunkedScores: toprangeEmbed = Embed( type='rich', color=EMBED_COLOR, description='\n'.join(map(format_score_inline, scoreChunk)) ) if first: toprangeEmbed.set_author( name=f'Top {rankstart} - {rankend} scores for {user["username"]}', url=osu.profile_link(user["user_id"]), icon_url=osu.profile_thumb(user["user_id"]), ) first = False await ctx.send(embed=toprangeEmbed)
async def osu_update(ctx: Context, *, u: Optional[str] = None, showhs: bool = True): if not u: u = get_osuid(ctx) if not u: return await ctx.send(f'No osu profile set for user {reply_mention(ctx)}. You can register your osu profile using the $register command or specify an osu user id to update directly with $update <uid>.') user = get_user(u) if not user: return await ctx.send(f'invalid user') osuid = user['user_id'] response = requests.post(f'{AMEO_API_ENDPOINT}update', params={'user': osuid, 'mode': 0}) if response.status_code != 200: if response.status_code == 400: return await ctx.send(f'Invalid update request, please make sure a valid user id was given/registered.') else: return await ctx.send('Something went wrong :( Try going to https://ameobea.me/osutrack/ to make sure you account stats are initialized.') r = response.json() updateEmbed = Embed( title=f'osu!track update for {r["username"]}', type='rich', color=EMBED_COLOR, description=( f'[osu! profile]({osu.profile_link(osuid)}) · [osu!track profile]({osu.track_profile_link(r["username"])})\n' f'**Rank**: {format_diff(r["pp_rank"])}\n' f'**PP**: {format_diff(round(r["pp_raw"], 4))}\n' f'**Playcount**: {r["playcount"]}\n' f'**Acc**: {format_diff(round(r["accuracy"], 2))}\n\n' f'**New Highscores**: {len(r["newhs"])}{f" {KEKW_EMOTE}" if len(r["newhs"]) == 0 else ""}\n' f'{chr(10).join(map(format_score_inline, r["newhs"][:5])) if showhs else ""}' f'{f"{chr(10)}..." if len(r["newhs"]) > 5 else ""}' ) ) updateEmbed.set_thumbnail(url=osu.profile_thumb(osuid)) await ctx.send(embed=updateEmbed) if showhs: hsEmbeds = [get_score_embed(hs, osuid, r["username"]) for hs in r["newhs"][:5]] for embed in hsEmbeds: await ctx.send(embed=embed)
def get_user_embed(user: osu.User) -> Embed: osuid = user['user_id'] userEmbed = Embed( title=( f'{flag(user["country"])} {user["username"]} - {float(user["pp_raw"]):n}pp | ' f'#{int(user["pp_rank"]):n} | ' f'{user["country"]} #{int(user["pp_country_rank"]):n}' ), url=osu.profile_link(osuid), type='rich', color=EMBED_COLOR, ) userEmbed.add_field( name='Ranked Score', value=f'{int(user["ranked_score"]):n}', inline=True ) userEmbed.add_field( name='Total score', value=f'{int(user["total_score"]):n}', inline=True, ) userEmbed.add_field( name='Hit Accuracy', value=f'{float(user["accuracy"]):.2f}%', inline=True, ) userEmbed.add_field( name='Play Count', value=f'{int(user["playcount"]):n}', inline=True, ) userEmbed.add_field( name='Play Time', value=format_seconds(int(user["total_seconds_played"])), inline=True, ) userEmbed.add_field( name='Level', value=f'{user["level"]}', inline=True, ) userEmbed.add_field( name='Grades', value=( f'{osu_score_emoji("XH")} \u200b {int(user["count_rank_ssh"]):n} \u200b ' f'{osu_score_emoji("SS")} \u200b {int(user["count_rank_ss"]):n} \u200b ' f'{osu_score_emoji("SH")} \u200b {int(user["count_rank_sh"]):n} \u200b ' f'{osu_score_emoji("S")} \u200b {int(user["count_rank_s"]):n} \u200b ' f'{osu_score_emoji("A")} \u200b {int(user["count_rank_a"]):n}' ), inline=False, ) userEmbed.set_thumbnail(url=osu.profile_thumb(osuid)) return userEmbed
def get_score_embed(score: osu.Score, osuid: str, username: str) -> Embed: if 'meta' not in score: score['meta'] = get_beatmap(score["beatmap_id"]) bmp = score['meta'] title = f'{bmp["title"]} [{bmp["version"]}] | {float(bmp["difficultyrating"]):.2f}★' description = ( f'**[{title}]({osu.beatmap_link(score["beatmap_id"])})\n' f'{osu_score_emoji(score["rank"])} | ' f'{osu.mod_string(int(score["enabled_mods"]))} | ' f'{get_score_acc(score)}% ({score["maxcombo"]}/{bmp["max_combo"]}) | ' f'{score["pp"] if "pp" in score else "?"}pp | ' f'{get_score_timedelta(score)}**\n' f'{OSU_HIT_EMOJI_MAP["300"]} {score["count300"]} ' f'{OSU_HIT_EMOJI_MAP["100"]} {score["count100"]}' f'{OSU_HIT_EMOJI_MAP["50"]} {score["count50"]} ' f'{OSU_HIT_EMOJI_MAP["miss"]} {score["countmiss"]}\n\n' f'**Beatmap Info** ({bmp["beatmap_id"]})' ) if int(score.get('replay_available', 0)) == 1: description += f' ([Replay]({osu.score_replay_link(score["score_id"])}))' description += ( f'\nLength **{format_seconds(int(bmp["total_length"]))}** ~ ' f'CS**{bmp["diff_size"]}** ' f'AR**{bmp["diff_approach"]}** ' f'OD**{bmp["diff_overall"]}** ' f'HP**{bmp["diff_drain"]}** ~ ' f'**{bmp["bpm"]}** BPM ~ ' f'**{float(bmp["difficultyrating"]):.2f}**★' ) scoreEmbed = Embed( type='rich', color=EMBED_COLOR, description=description, ) authortitle = f'{username} - #{score["ranking"] + 1} Top Play' if 'ranking' in score and score['ranking'] >= 0 else username scoreEmbed.set_author(name=authortitle, url=osu.profile_link(osuid), icon_url=osu.profile_thumb(osuid)) scoreEmbed.set_thumbnail(url=osu.beatmap_thumb(bmp['beatmapset_id'])) return scoreEmbed