async def zeah_command(self, ctx, *username): """ Blood and soul rune calculator """ safe_username = '******'.join(username) user = Zeah(safe_username) bloods = GrandExchange("Blood rune") souls = GrandExchange("Soul rune") async with ctx.typing(): await user.fetch() embed = discord.Embed(title="Zeah runecrafting calculator", description=f'**{user.runecraft_level}** Runecraft ({user.runecraft_xp:,} xp)' f' | {safe_username}') embed.set_thumbnail(url=get_icon_url("runecraft")) footer = f'{next_level_string(user.runecraft_xp, "runecraft")}' if user.runecraft_level < 77: embed.add_field(name="Level too low", value="You need a runecraft level of at least 77 to make blood runes", inline=True) elif user.runecraft_level < 90: await bloods.fetch() embed.add_field(name="Bloods to level up", value=f'{user.bloods_to_level_up() + 1:,.0f}\n' f'~{nice_price(user.bloods_to_level_up() * bloods.current_price)}\n' f'({user.blood_trips_to_level_up() + 1:,.0f} trips)', inline=True) embed.add_field(name="Bloods to level 99", value=f'{user.bloods_to_level_99() + 1:,.0f}\n' f'~{nice_price(user.bloods_to_level_99() * bloods.current_price)}\n' f'({user.blood_trips_to_level_99() + 1:,.0f} trips)', inline=True) footer += f'\nBlood rune price: {bloods.current_price} gp' else: await bloods.fetch() await souls.fetch() embed.add_field(name="Bloods to level up", value=f'{user.bloods_to_level_up() + 1:,.0f}\n' f'~{nice_price(user.bloods_to_level_up() * bloods.current_price)}\n' f'({user.blood_trips_to_level_up() + 1:,.0f} trips)', inline=True) embed.add_field(name="Souls to level up", value=f'{user.souls_to_level_up() + 1:,.0f}\n' f'~{nice_price(user.souls_to_level_up() * souls.current_price)}\n' f'({user.soul_trips_to_level_up() + 1:,.0f} trips)', inline=True) footer += f'\nBlood rune price: {bloods.current_price} gp\n' \ f'Soul rune price: {souls.current_price} gp' if user.runecraft_level < 99: embed.add_field(name="Bloods to level 99", value=f'{user.bloods_to_level_99() + 1:,.0f}\n' f'~{nice_price(user.bloods_to_level_99() * bloods.current_price)}\n' f'({user.blood_trips_to_level_99() + 1:,.0f} trips)', inline=True) embed.add_field(name="Souls to level 99", value=f'{user.souls_to_level_99() + 1:,.0f}\n' f'~{nice_price(user.souls_to_level_99() * souls.current_price)}\n' f'({user.soul_trips_to_level_99() + 1:,.0f} trips)', inline=True) embed.set_footer(text=footer) await ctx.send(f'{ctx.message.author.mention}', embed=embed) return
async def ge_command(self, ctx, *search_description): """ Responds with information about an item from the Grand Exchange """ safe_name = ' '.join(search_description).lower() url_safe_name = safe_name.replace(' ', '+') ge = GrandExchange(safe_name) time = datetime.now() timezone = pytz.timezone("America/Los_Angeles") pst_time = timezone.localize(time) if ge.multiple_results: embed = discord.Embed(title="Grand Exchange", description=f'There are multiple results for `{safe_name}`', url=f'{ge_url}{url_safe_name}', timestamp=pst_time) embed.add_field(name="Results", value=ge.get_possible_matches_str()) await ctx.send(embed=embed) def check(msg): return msg.content in [str(i) for i in range(1, len(ge.matches) + 1)]\ and msg.channel == ctx.channel\ and msg.author == ctx.message.author try: choice = await ctx.bot.wait_for('message', check=check, timeout=10) except asyncio.TimeoutError: print(f'Timeout on choice from {ctx.message.author}.') else: name = f'{ge.matches[int(choice.content) - 1]["name"].lower()}' await ctx.send(f'!b price {name}') async with ctx.typing(): await ctx.invoke(self.ge_command, name) else: embed = discord.Embed(title=ge.name, description=ge.description, url=f'{ge_url}{url_safe_name}', timestamp=pst_time) if ge.todays_price_trend == 'positive': embed.color = discord.Colour.dark_green() elif ge.todays_price_trend == 'negative': embed.color = discord.Colour.dark_red() embed.set_thumbnail(url=ge.icon) embed.add_field(name='Price', value=f'**{ge.current_price}** gp', inline=False) embed.add_field(name='Today\'s trend', value=f'**{ge.todays_price_change}** change today, trending *{ge.todays_price_trend}*') embed.add_field(name="Change", value=f'**{ge.day30_change}** over the last month\n' f'**{ge.day90_change}** over the last 3 months\n' f'**{ge.day180_change}** over the last 6 months') other_info = f'High alch: {ge.high_alch} gp \u2022 {ge.buy_limit} buy limit' if ge.is_members: embed.set_footer(text=f'{other_info}\nMembers item', icon_url=members_icon) else: embed.set_footer(text=f'{other_info}\nNon members item') # Graph ge.generate_graph() file = discord.File('assets/graph.png', filename='graph.png') embed.set_image(url='attachment://graph.png') await ctx.send(f'{ctx.message.author.mention}', embed=embed, file=file) file.close() return
def __init__(self, username): Hiscore.__init__(self, username) GrandExchange.__init__(self, "Nature rune")
async def fetch(self): """ Fetch the results """ Hiscore.__init__(self, self.username) GrandExchange.__init__(self, "Nature rune") await Hiscore.fetch(self) await GrandExchange.fetch(self)