Example #1
0
        async def connect(ctx, *args):
            color = ctx.message.author.roles[len(ctx.message.author.roles) -
                                             1].color

            if len(args) == 0:
                return await ctx.send('Must provide a username!')

            msg = '{}'.format(' '.join(args))

            if osuhelper.get_id(msg) == "Couldn't find user!":
                return await ctx.send("Couldn't find this user!")
            userid = osuhelper.get_id(msg)

            owo = db.search(User.id == ctx.message.author.id)

            if str(owo) == '[]':
                db.insert({'id': ctx.message.author.id, 'akatsuki': userid})
            else:
                db.update({'akatsuki': userid},
                          User.id == ctx.message.author.id)

            embed = discord.Embed(colour=color)
            embed.set_author(
                name=f"User {msg} was connected to your discord account!",
                url=f"https://akatsuki.pw/u/{userid}")
            embed.set_image(url="https://a.akatsuki.pw/{}.png".format(userid))
            return await ctx.send(embed=embed)
Example #2
0
        async def _recent(ctx, *args):
            color = ctx.message.author.roles[len(ctx.message.author.roles) -
                                             1].color

            relax, mode, scoreid = 0, 0, 0
            msg = ctx.message.content.split(' ')[1:]

            if '-rx' in msg:
                msg.remove('-rx')
                relax = 1
            if '-p' in msg:
                scoreid = int(msg[msg.index('-p') + 1])
                msg.remove(msg[msg.index('-p') + 1])
                msg.remove('-p')
            if '-std' in msg:
                msg.remove('-std')
                mode = 0
            elif '-taiko' in msg:
                msg.remove('-taiko')
                mode = 1
            elif '-ctb' in msg:
                msg.remove('-ctb')
                mode = 2
            elif '-mania' in msg:
                msg.remove('-mania')
                mode, relax = 3, 0

            hahaha = another_switcher[relax]
            text = switcher[mode]

            if ctx.message.mentions:
                e = db.get(User.id == ctx.message.mentions[0].id)
                if e == None:
                    return await ctx.send(
                        f"User couldn't be found in our database! Try connecting a user to our database by doing `{get_prefix(Chiyo, ctx.message)}connect user`"
                    )
                userid = e['akatsuki']
            elif len(msg) == 0:
                e = db.get(User.id == ctx.message.author.id)
                if e == None:
                    return await ctx.send(
                        f"User couldn't be found in our database! Try connecting a user to our database by doing `{get_prefix(Chiyo, ctx.message)}connect user`"
                    )
                userid = e['akatsuki']
            else:
                e = osuhelper.get_id(' '.join(msg))
                if e == "Couldn't find user!":
                    return await ctx.send("Couldn't find this user!")
                userid = e

            info = osuhelper.Helper(userid)
            stats = info.recent(mode=mode, relax=relax, scoreid=scoreid)
            if stats == 'error':
                return await ctx.send("Error has occured!")

            rank = config.letters.get(stats['rank'])
            pp = round(stats['pp'], 2)
            ar = stats['beatmap']['ar']
            od = stats['beatmap']['od']
            accuracy = round(stats['accuracy'], 2)
            score = stats['score']
            max_combo = stats['max_combo']
            full_combo = stats['beatmap']['max_combo']
            count_300 = stats['count_300']
            count_100 = stats['count_100']
            count_50 = stats['count_50']
            count_miss = stats['count_miss']
            completed = 'Yes' if stats['completed'] == 3 or stats[
                'completed'] == 2 else 'No'
            songname = stats['beatmap']['song_name']
            mods = 'NM' if stats['mods'] == 0 else osuhelper.readableMods(
                stats['mods'])
            difficulty = round(stats['beatmap']['difficulty2'][man[mode]], 2)
            beatmap_id = stats['beatmap']['beatmap_id']
            beatmapset_id = stats['beatmap']['beatmapset_id']
            username = osuhelper.get_username(userid)

            cache[ctx.message.channel.id] = osuhelper.get_beatmap(
                beatmap_id, mode)

            embed = discord.Embed(
                description=
                f'▸ {pp}PP [{"".join(oppai(beatmap_id, mods, accuracy)) if mode == 0 and completed == "Yes" and relax == 0 else f"AR: {ar} OD: {od}"}] ▸ {accuracy}%\n▸ {score} ▸ {max_combo}x/{full_combo}x ▸ [{count_300}/{count_100}/{count_50}/{count_miss}]\n▸ Map Completed: {completed}',
                color=color)
            embed.set_author(name=f"{songname} +{mods} [{difficulty}★]",
                             url=f"https://akatsuki.pw/b/{beatmap_id}",
                             icon_url=rank)
            embed.set_thumbnail(url=f"https://a.akatsuki.pw/{userid}.png")
            embed.set_image(
                url=
                f"https://assets.ppy.sh/beatmaps/{beatmapset_id}/covers/cover.jpg"
            )
            embed.set_footer(
                text=f"Most Recent osu!{hahaha} {text} Play for {username} ")
            await ctx.send(embed=embed)
Example #3
0
        async def _profile(ctx, *args):
            color = ctx.message.author.roles[len(ctx.message.author.roles) -
                                             1].color

            relax, mode = 0, 0
            msg = ctx.message.content.split(' ')[1:]

            if '-rx' in msg:
                msg.remove('-rx')
                relax = 1
            if '-std' in msg:
                msg.remove('-std')
                mode = 0
            elif '-taiko' in msg:
                msg.remove('-taiko')
                mode = 1
            elif '-ctb' in msg:
                msg.remove('-ctb')
                mode = 2
            elif '-mania' in msg:
                msg.remove('-mania')
                mode, relax = 3, 0

            hahaha = another_switcher[relax]
            text = switcher[mode]

            if ctx.message.mentions:
                e = db.get(User.id == ctx.message.mentions[0].id)
                if e == None:
                    return await ctx.send(
                        f"User couldn't be found in our database! Try connecting a user to our database by doing `{get_prefix(Chiyo, ctx.message)}connect user`"
                    )
                userid = e['akatsuki']
            elif len(msg) == 0:
                e = db.get(User.id == ctx.message.author.id)
                if e == None:
                    return await ctx.send(
                        f"User couldn't be found in our database! Try connecting a user to our database by doing `{get_prefix(Chiyo, ctx.message)}connect user`"
                    )
                userid = e['akatsuki']
            else:
                if osuhelper.get_id(' '.join(msg)) == "Couldn't find user!":
                    return await ctx.send("Couldn't find this user!")
                userid = osuhelper.get_id(' '.join(msg))

            e = osuhelper.Helper(userid)

            b = e.profile(mode=mode, relax=relax)
            if b == 'error':
                return await ctx.send("Error has occured!")
            official_rank = b['stats']['global_leaderboard_rank']
            country = b['country']
            country_rank = b['stats']['country_leaderboard_rank']
            level = round(b['stats']['level'], 2)
            pp = b['stats']['pp']
            accuracy = round(b['stats']['accuracy'], 2)
            playcount = b['stats']['playcount']
            username = b['username']
            embed = discord.Embed(
                description=
                f'▸ Official Rank: {official_rank} ({country}#{country_rank}) \n▸ Level: {level}\n▸ Total PP: {pp} \n▸ Accuracy: {accuracy}% \n▸ Playcount: {playcount}',
                color=color)
            embed.set_author(
                name=f"osu!{hahaha} {text} Profile for {username} ",
                url=f"https://akatsuki.pw/u/{userid}",
                icon_url=config.server_icon_url)
            embed.set_thumbnail(url=f"https://a.akatsuki.pw/{userid}.png")
            embed.set_footer(text=f"Player on Akatsuki!")
            return await ctx.send(embed=embed)
Example #4
0
        async def _compare(ctx, *args):
            color = ctx.message.author.roles[len(ctx.message.author.roles) -
                                             1].color
            try:
                relax, mode, scoreid = 0, int(
                    cache[ctx.message.channel.id]['mode']), 0
            except:
                return await ctx.send("Couldn't find a map in this channel!")
            msg = ctx.message.content.split(' ')[1:]

            if '-rx' in msg:
                msg.remove('-rx')
                relax = 1
            if '-p' in msg:
                scoreid = int(msg[msg.index('-p') + 1])
                msg.remove(msg[msg.index('-p') + 1])
                msg.remove('-p')
            if '-std' in msg:
                msg.remove('-std')
                mode = 0
            elif '-taiko' in msg:
                msg.remove('-taiko')
                mode = 1
            elif '-ctb' in msg:
                msg.remove('-ctb')
                mode = 2
            elif '-mania' in msg:
                msg.remove('-mania')
                mode, relax = 3, 0

            hahaha = another_switcher[relax]
            text = switcher[mode]

            if ctx.message.mentions:
                e = db.get(User.id == ctx.message.mentions[0].id)
                if e == None:
                    return await ctx.send(
                        f"User couldn't be found in our database! Try connecting a user to our database by doing `{get_prefix(Chiyo, ctx.message)}connect user`"
                    )
                userid = e['akatsuki']
            elif len(msg) == 0:
                e = db.get(User.id == ctx.message.author.id)
                if e == None:
                    return await ctx.send(
                        f"User couldn't be found in our database! Try connecting a user to our database by doing `{get_prefix(Chiyo, ctx.message)}connect user`"
                    )
                userid = e['akatsuki']
            else:
                if osuhelper.get_id(' '.join(msg)) == "Couldn't find user!":
                    return await ctx.send("Couldn't find this user!")
                userid = osuhelper.get_id(' '.join(msg))

            info = osuhelper.Helper(userid)
            if ctx.message.channel.id not in cache:
                return await ctx.send("Couldn't find a map here")

            stats = info.compare(
                beatmapid=cache[ctx.message.channel.id]['beatmap_id'],
                mode=mode,
                relax=relax,
                scoreid=scoreid)

            if stats == 'no score found':
                return await ctx.send("Couldn't find a score for this user!")

            rank = config.letters.get(stats['rank'])
            pp = round(float(stats['pp']), 2)
            ar = cache[ctx.message.channel.id]['diff_approach']
            od = cache[ctx.message.channel.id]['diff_overall']
            score = stats['score']
            max_combo = stats['maxcombo']
            full_combo = cache[ctx.message.channel.id]['max_combo']
            count_300 = stats['count300']
            count_100 = stats['count100']
            count_50 = stats['count50']
            count_miss = stats['countmiss']
            songname = cache[ctx.message.channel.id]['title']
            mods = 'NM' if int(
                stats['enabled_mods']) == 0 else osuhelper.readableMods(
                    int(stats['enabled_mods']))
            difficulty = round(
                float(cache[ctx.message.channel.id]['difficultyrating']), 2)
            beatmap_id = cache[ctx.message.channel.id]['beatmap_id']
            beatmapset_id = cache[ctx.message.channel.id]['beatmapset_id']
            if mode == 0:
                total = sum((int(count_300), int(count_100), int(count_50),
                             int(count_miss)))
                d = 100.0 * sum((int(count_50) * 50.0, int(count_100) * 100.0,
                                 int(count_300) * 300.0)) / (total * 300.0)
                accuracy = round(d, 2)
            elif mode == 1:
                total = sum((int(count_300), int(count_100), int(count_miss)))
                d = 100.0 * sum((int(count_100) * 150.0,
                                 int(count_300) * 300.0)) / (total * 300.0)
                accuracy = round(d, 2)
            else:
                accuracy = '0'

            username = osuhelper.get_username(userid)

            embed = discord.Embed(
                description=
                f'▸ {pp}PP [{"".join(oppai(beatmap_id, mods, accuracy)) if mode == 0 and relax == 0 else f"AR: {ar} OD: {od}"}] ▸ {accuracy}%\n▸ {score} ▸ {max_combo}x/{full_combo}x ▸ [{count_300}/{count_100}/{count_50}/{count_miss}]',
                color=color)
            embed.set_author(name=f"{songname} +{mods} [{difficulty}★]",
                             url=f"https://akatsuki.pw/b/{beatmap_id}",
                             icon_url=rank)
            embed.set_thumbnail(url=f"https://a.akatsuki.pw/{userid}.png")
            embed.set_image(
                url=
                f"https://assets.ppy.sh/beatmaps/{beatmapset_id}/covers/cover.jpg"
            )
            embed.set_footer(text=f"osu!{hahaha} {text} Plays for {username} ")
            await ctx.send(embed=embed)