From e65be93751a929b71509dc6f2921bcae4f369b24 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Fri, 3 Mar 2023 15:46:56 +0000 Subject: [PATCH 1/7] Add database file for user isotokens data --- database/isotokens.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 database/isotokens.json diff --git a/database/isotokens.json b/database/isotokens.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/database/isotokens.json @@ -0,0 +1 @@ +{} From f3ce4d73f61f2c90e3e8d697245f21fee5a7064a Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Fri, 3 Mar 2023 15:49:38 +0000 Subject: [PATCH 2/7] Add database loading and saving support for isotokens database --- main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.py b/main.py index 6acfa929..ebea88cc 100644 --- a/main.py +++ b/main.py @@ -36,6 +36,7 @@ with open('database/levels.json', 'r') as f: levels = json.load(f) with open('config/commands.json', 'r') as f: commandsdb = json.load(f) with open('database/automod.json', 'r') as f: automod_config = json.load(f) +with open('database/isotokens.json', 'r') as f: isotokens = json.load(f) #Pre-Initialization Commands def timenow(): datetime.datetime.now().strftime("%H:%M:%S") @@ -45,6 +46,7 @@ def save(): with open('database/presence.json', 'w+') as f: json.dump(presence, f, indent=4) with open('database/levels.json', 'w+') as f: json.dump(levels, f, indent=4) with open('database/automod.json', 'w+') as f: json.dump(automod_config, f, indent=4) + with open('database/isotokens.json', 'w+') as f: json.dump(isotokens, f, indent=4) def get_user_networth(user_id:int): nw = get_wallet(user_id) + get_bank(user_id) From 1f095661e83230f447723b2e3cb94f9820433612 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sat, 4 Mar 2023 06:15:29 +0000 Subject: [PATCH 3/7] Make daily command for IsoCoin system --- main.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.py b/main.py index ebea88cc..d54648e5 100644 --- a/main.py +++ b/main.py @@ -432,6 +432,20 @@ async def profile(ctx: ApplicationContext, user: discord.User = None): # Maybe I should make a userdat system for collecting statistical data to process and display here, coming in a future update. await ctx.respond(embed=localembed) +# IsoCoins commands +isocoin_system = client.create_group("isocoin", "Commands related to the IsoCoin rewards system") + +isocoin_system.command( + name="daily", + description="Collect your daily reward of IsoCoins" +) +@commands.cooldown(1, 86400, commands.BucketType.user) +async def isocoin_daily(ctx: ApplicationContext): + isocoins_reward = random.randint(2500, 5000) + isotokens[str(ctx.author.id)] += isocoins_reward + save() + await ctx.respond(f"You have earned {isocoins_reward} IsoCoins from this daily. Come back in 24 hours for the next one!") + # Initialization active_cogs = ["economy", "maths", "moderation", "reddit", "minigames", "automod", "isobank", "levelling", "fun"] i = 1 From 35ca4859c50261b8c23356ccce4182e62227c7d6 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sat, 4 Mar 2023 06:19:28 +0000 Subject: [PATCH 4/7] Add basic implementation for IsoCoin shop --- main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index d54648e5..a94d0e58 100644 --- a/main.py +++ b/main.py @@ -433,7 +433,7 @@ async def profile(ctx: ApplicationContext, user: discord.User = None): await ctx.respond(embed=localembed) # IsoCoins commands -isocoin_system = client.create_group("isocoin", "Commands related to the IsoCoin rewards system") +isocoin_system = client.create_group("isocoin", "Commands related to the IsoCoin rewards system.") isocoin_system.command( name="daily", @@ -446,6 +446,13 @@ async def isocoin_daily(ctx: ApplicationContext): save() await ctx.respond(f"You have earned {isocoins_reward} IsoCoins from this daily. Come back in 24 hours for the next one!") +isocoin_system.command( + name="shop", + description="See all the items that you can buy using your IsoCoins." +) +async def isocoin_shop(ctx: ApplicationContext): + await ctx.respond("IsoCoin shop is coming soon! Check back later for new items.") + # Initialization active_cogs = ["economy", "maths", "moderation", "reddit", "minigames", "automod", "isobank", "levelling", "fun"] i = 1 From 45e20de8f7223d4be09e33789601a4b7426e7074 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sat, 4 Mar 2023 12:38:14 +0000 Subject: [PATCH 5/7] Fix isocoins variable name --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index a94d0e58..24fb4f31 100644 --- a/main.py +++ b/main.py @@ -36,7 +36,7 @@ with open('database/levels.json', 'r') as f: levels = json.load(f) with open('config/commands.json', 'r') as f: commandsdb = json.load(f) with open('database/automod.json', 'r') as f: automod_config = json.load(f) -with open('database/isotokens.json', 'r') as f: isotokens = json.load(f) +with open('database/isotokens.json', 'r') as f: isocoins = json.load(f) #Pre-Initialization Commands def timenow(): datetime.datetime.now().strftime("%H:%M:%S") @@ -46,7 +46,7 @@ def save(): with open('database/presence.json', 'w+') as f: json.dump(presence, f, indent=4) with open('database/levels.json', 'w+') as f: json.dump(levels, f, indent=4) with open('database/automod.json', 'w+') as f: json.dump(automod_config, f, indent=4) - with open('database/isotokens.json', 'w+') as f: json.dump(isotokens, f, indent=4) + with open('database/isotokens.json', 'w+') as f: json.dump(isocoins, f, indent=4) def get_user_networth(user_id:int): nw = get_wallet(user_id) + get_bank(user_id) @@ -442,7 +442,7 @@ async def profile(ctx: ApplicationContext, user: discord.User = None): @commands.cooldown(1, 86400, commands.BucketType.user) async def isocoin_daily(ctx: ApplicationContext): isocoins_reward = random.randint(2500, 5000) - isotokens[str(ctx.author.id)] += isocoins_reward + isocoins[str(ctx.author.id)] += isocoins_reward save() await ctx.respond(f"You have earned {isocoins_reward} IsoCoins from this daily. Come back in 24 hours for the next one!") From e25af5caa438905b6329287587e72f25cc2c6f8d Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sat, 4 Mar 2023 12:39:13 +0000 Subject: [PATCH 6/7] Add default user key value in isocoin database system --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index 24fb4f31..7657fd8d 100644 --- a/main.py +++ b/main.py @@ -130,6 +130,7 @@ async def on_ready(): async def on_message(ctx): new_wallet(ctx.author.id) new_bank(ctx.author.id) + if str(ctx.author.id) not in isocoins: isocoins[str(ctx.author.id)] = 0 if str(ctx.guild.id) not in warnings: warnings[str(ctx.guild.id)] = {} if str(ctx.author.id) not in warnings[str(ctx.guild.id)]: warnings[str(ctx.guild.id)][str(ctx.author.id)] = [] if str(ctx.author.id) not in items: items[str(ctx.author.id)] = {} From 4d3ebc4976874a030f826ce9c736035dda49870f Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sat, 4 Mar 2023 12:47:05 +0000 Subject: [PATCH 7/7] Add command to check user's IsoCoins balance --- main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.py b/main.py index 7657fd8d..4b0f2ad1 100644 --- a/main.py +++ b/main.py @@ -436,6 +436,14 @@ async def profile(ctx: ApplicationContext, user: discord.User = None): # IsoCoins commands isocoin_system = client.create_group("isocoin", "Commands related to the IsoCoin rewards system.") +isocoin_system.command( + name="balance", + description="See your IsoCoin balances" +) +async def isocoin_balance(ctx: ApplicationContext): + localembed = discord.Embed(description=f"You currently have **{isocoins[str(ctx.author.id)]}** IsoCoins.") + await ctx.respond(embed=localembed) + isocoin_system.command( name="daily", description="Collect your daily reward of IsoCoins"