def format_user_diff(mode: api.GameMode, pp: float, rank: int, country_rank: int, accuracy: float, iso: str, data: dict): """ Get a bunch of differences and return a formatted string to send. iso is the country code. """ formatted = "\u2139`{} {:.2f}pp {:+.2f}pp`".format( mode.name.replace("Standard", "osu!"), float(data["pp_raw"]), pp) formatted += (" \U0001f30d`#{:,}{}`".format( int(data["pp_rank"]), "" if int(rank) == 0 else " {:+}".format(int(rank)))) formatted += (" {}`#{:,}{}`".format( utils.text_to_emoji(iso), int(data["pp_country_rank"]), "" if int(country_rank) == 0 else " {:+}".format(int(country_rank)))) rounded_acc = round(accuracy, 3) if rounded_acc > 0: formatted += " \U0001f4c8" # Graph with upwards trend elif rounded_acc < 0: formatted += " \U0001f4c9" # Graph with downwards trend else: formatted += " \U0001f3af" # Dart formatted += "`{:.3f}%".format(float(data["accuracy"])) if not rounded_acc == 0: formatted += " {:+}%`".format(rounded_acc) else: formatted += "`" return formatted
async def convert(message: discord.Message, value: float, currency_from: str.upper, currency_to: str.upper): """ Converts currency using http://fixer.io/ """ try: rate = await get_exchange_rate(currency_from, currency_to) except ValueError as e: await client.say(message, e) else: flag = utils.text_to_emoji(currency_to[:2]) e = discord.Embed(description="{} {:,.2f} {}".format( flag, value * rate, currency_to), color=message.author.color) await client.send_message(message.channel, embed=e)