def calculate_tax(self, ctx: CommandContext, data: str) -> str: log.info("%s - searching for %s\n", ctx.channel, data) lang = self.db.get_lang(ctx.channel) try: USAGE = localized_string(lang, "taxUsage") if not data: return USAGE parts = data.split() if len(parts) < 2: return localized_string(lang, "taxUsage") amount = safe_int(parts[0], 0) if amount == 0: return USAGE query = " ".join(parts[1:]) tax_amount = EFT.check_tax(lang, amount, query) if not tax_amount: return USAGE (tax, model) = tax_amount profit = amount - tax return localized_string( lang, "twitch_tax", model.name, format(int(amount), ","), format(int(tax), ","), format(int(profit), ","), maya.MayaDT.from_datetime(model.updated).slang_time(), ) except Exception as e: print(e) return localized_string( lang, "searchFailed", )
def calculate_tax(self, ctx: CommandContext, data: str) -> str: log.info("%s - searching for %s\n", ctx.channel, data) lang = self.db.get_lang(ctx.channel) try: USAGE = localized_string(lang, "taxUsage") if not data: return USAGE parts = data.split() if len(parts) < 2: return localized_string(lang, "taxUsage") amount = safe_int(parts[0], 0) if amount == 0: return USAGE query = " ".join(parts[1:]) tax_amount = EFT.check_tax(lang, amount, query) if not tax_amount: return USAGE (tax, model) = tax_amount profit = amount - tax embed = discord.Embed( title=model.name, url=model.wikiLink, color=0x780A81, ) embed.set_thumbnail(url=model.img) embed.add_field( name=localized_string(lang, "taxBasePrice"), value=format(int(model.basePrice), ",") + " ₽", inline=True, ) embed.add_field( name=localized_string(lang, "taxBaseTax"), value=format(int(tax), ",") + " ₽", inline=True, ) embed.add_field( name=localized_string(lang, "taxProfit"), value=format(int(profit), ",") + " ₽", inline=True, ) embed.set_footer( text=localized_string(lang, "marketUpdated") + maya.MayaDT.from_datetime(model.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 map name ; please try again.", inline=True, ) return embed