From c9556cb51c0e250527358ed569e0b8ea45959a6d Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sun, 12 Mar 2023 04:37:09 +0000 Subject: [PATCH 1/4] Convert response embed in `/buy` to multi-liner --- cogs/economy.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cogs/economy.py b/cogs/economy.py index 5ec4be6c..4a0c4191 100644 --- a/cogs/economy.py +++ b/cogs/economy.py @@ -360,7 +360,13 @@ async def buy(self, ctx: ApplicationContext, name: str, quantity: int=1): currency['wallet'][str(ctx.author.id)] -= int(amt) items[str(ctx.author.id)][str(name)] += quantity save() - await ctx.respond(embed=discord.Embed(title=f'You just bought {quantity} {shopitem[name]["stylized name"]}!', description='Thank you for your purchase.', color=discord.Color.green())) + await ctx.respond( + embed=discord.Embed( + title=f'You just bought {quantity} {shopitem[name]["stylized name"]}!', + description='Thank you for your purchase.', + color=discord.Color.green() + ) + ) except KeyError: await ctx.respond('That item doesn\'t exist.') @commands.slash_command( From 4917e7a663c295a61d94c90466227fbc1729390e Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sun, 12 Mar 2023 04:56:39 +0000 Subject: [PATCH 2/4] Add tax and taxable amount display on purchase invoice embed in `/buy` --- cogs/economy.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cogs/economy.py b/cogs/economy.py index 4a0c4191..5f4a2301 100644 --- a/cogs/economy.py +++ b/cogs/economy.py @@ -357,14 +357,22 @@ async def buy(self, ctx: ApplicationContext, name: str, quantity: int=1): if (currency['wallet'][str(ctx.author.id)] < amt): return await ctx.respond('You don\'t have enough balance to buy this.') if (shopitem[name]['available'] == False): return await ctx.respond('You can\'t buy this item **dood**') if (quantity <= 0): return await ctx.respond('The specified quantity cannot be less than `1`!') - currency['wallet'][str(ctx.author.id)] -= int(amt) + tax = 3 + taxable_amount = (amt / 100) * tax + rounded_taxable_amount = math.floor(taxable_amount) + total_amount = amt + rounded_taxable_amount + currency['wallet'][str(ctx.author.id)] -= int(total_amount) items[str(ctx.author.id)][str(name)] += quantity save() + localembed = discord.Embed( + title=f'You just bought {quantity} {shopitem[name]["stylized name"]}!', + description=f"**Your Purchase Invoice**\n\nItem: {quantity} {name.lower()}\n---------------\nBase Amount: {amt} coins\nTax: 3%\nTaxable Amount: {taxable_amount} coins\nTaxable Amount (rounded): {rounded_taxable_amount}coins\n**Charged Amount:** {total_amount} coins", + color=discord.Color.green() + ) + localembed.set_footer(text="Thank you for your purchase.") await ctx.respond( embed=discord.Embed( - title=f'You just bought {quantity} {shopitem[name]["stylized name"]}!', - description='Thank you for your purchase.', - color=discord.Color.green() + ) ) except KeyError: await ctx.respond('That item doesn\'t exist.') From a1a2315b7d46620bde983a02be29fbf46112caec Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sun, 12 Mar 2023 05:03:15 +0000 Subject: [PATCH 3/4] Fix `/buy` command response function --- cogs/economy.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cogs/economy.py b/cogs/economy.py index 5f4a2301..974bec2d 100644 --- a/cogs/economy.py +++ b/cogs/economy.py @@ -370,11 +370,7 @@ async def buy(self, ctx: ApplicationContext, name: str, quantity: int=1): color=discord.Color.green() ) localembed.set_footer(text="Thank you for your purchase.") - await ctx.respond( - embed=discord.Embed( - - ) - ) + await ctx.respond(embed=localembed) except KeyError: await ctx.respond('That item doesn\'t exist.') @commands.slash_command( From 325717302d9db8b338a15ab1f22720901303f935 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sun, 12 Mar 2023 05:08:05 +0000 Subject: [PATCH 4/4] Fix grammar error in `/buy` embed --- cogs/economy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/economy.py b/cogs/economy.py index 974bec2d..af13c18d 100644 --- a/cogs/economy.py +++ b/cogs/economy.py @@ -366,7 +366,7 @@ async def buy(self, ctx: ApplicationContext, name: str, quantity: int=1): save() localembed = discord.Embed( title=f'You just bought {quantity} {shopitem[name]["stylized name"]}!', - description=f"**Your Purchase Invoice**\n\nItem: {quantity} {name.lower()}\n---------------\nBase Amount: {amt} coins\nTax: 3%\nTaxable Amount: {taxable_amount} coins\nTaxable Amount (rounded): {rounded_taxable_amount}coins\n**Charged Amount:** {total_amount} coins", + description=f"**Your Purchase Invoice**\n\nItem: {quantity} {name.lower()}\n---------------\nBase Amount: {amt} coins\nTax: 3%\nTaxable Amount: {taxable_amount} coins\nTaxable Amount (rounded): {rounded_taxable_amount} coins\n**Charged Amount:** {total_amount} coins", color=discord.Color.green() ) localembed.set_footer(text="Thank you for your purchase.")