def bot_price(self, ctx: CommandContext, data: str) -> Union[str, discord.Embed]: log.info("%s - searching for %s (new)\n", ctx.channel, data) lang = self.db.get_lang(ctx.channel) try: price = EFT.check_price(lang, data) embed = discord.Embed( title=price.name, url=price.wikiLink, color=0x780A81, ) embed.set_thumbnail(url=price.img) embed.add_field( name=localized_string(lang, "marketPrice"), value=format(int(price.price), ","), inline=True, ) embed.add_field( name=localized_string(lang, "marketTrader"), value=price.traderName, inline=True, ) embed.add_field( name=localized_string(lang, "marketTraderPrice"), value=format(int(price.traderPrice), ","), inline=True, ) embed.add_field( name=localized_string(lang, "marketSlot"), value=format(round((price.price / price.slots)), ","), inline=True, ) embed.add_field( name=localized_string(lang, "market7dAvg"), value=format(int(price.avg7daysPrice), ","), inline=True, ) embed.add_field( name=localized_string(lang, "market24hAvg"), value=format(int(price.avg24hPrice), ","), inline=True, ) embed.set_footer( text=localized_string(lang, "marketUpdated") + maya.MayaDT.from_datetime(price.updated).slang_time()) return embed except: embed = discord.Embed( title="LogicEFTBot - Error", color=0x780A81, ) embed.set_thumbnail(url="https://illogical.network/api/error.png") embed.add_field( name="Invalid Item Search", value="You've entered in an invalid item ; please try again.", inline=True, ) return embed
def bot_wiki(self, ctx: CommandContext, data: str) -> str: log.info("%s - searching for %s\n", ctx.channel, data) lang = self.db.get_lang(ctx.channel) wiki = EFT.check_price(lang, data) try: return localized_string(lang, "twitch_wiki", wiki.name, wiki.wikiLink) except: return localized_string( lang, "searchFailed", )
def bot_avg24h(self, ctx: CommandContext, data: str) -> str: log.info("%s - searching for %s\n", ctx.channel, data) lang = self.db.get_lang(ctx.channel) try: avg24h = EFT.check_price(lang, data) return localized_string( lang, "twitch_avg24h", avg24h.name, format(int(avg24h.avg24hPrice), ","), maya.MayaDT.from_datetime(avg24h.updated).slang_time(), ) except: return localized_string( lang, "searchFailed", )
def bot_slot(self, ctx: CommandContext, data: str) -> str: log.info("%s - searching for %s\n", ctx.channel, data) lang = self.db.get_lang(ctx.channel) try: slot = EFT.check_price(lang, data) return localized_string( lang, "twitch_slot", slot.name, format(int((slot.price / slot.slots)), ","), maya.MayaDT.from_datetime(slot.updated).slang_time(), ) except Exception as e: print(e) return localized_string( lang, "searchFailed", )
def bot_trader(self, ctx: CommandContext, data: str) -> str: log.info("%s - searching for %s\n", ctx.channel, data) lang = self.db.get_lang(ctx.channel) trader = EFT.check_price(lang, data) try: return localized_string( lang, "twitch_trader", trader.name, trader.traderName, format(int(trader.traderPrice), ","), maya.MayaDT.from_datetime(trader.updated).slang_time(), ) except: return localized_string( lang, "searchFailed", )