Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions cogs/isocoin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""The isobot cog file for the IsoCoin system."""

# Imports
import random
import json
import discord
from discord import ApplicationContext, SlashCommandGroup
from discord.ext import commands

# Variables
with open("database/isotokens.json", 'r', encoding="utf-8") as f: isocoins = json.load(f)

def save():
with open("database/isotokens.json", 'w+', encoding="utf-8") as f: json.dump(isocoins, f)

# Functions
def create_isocoin_key(user_id: int) -> int:
"""Creates a new isocoin key and value for the specified user.\n\nReturns `0` if successful, returns `1` if user is already cached."""
if str(user_id) not in isocoins:
isocoins[str(user_id)] = 0
return 0
else: return 1

# Commands
class IsoCoin(commands.Cog):
def __init__(self, bot):
self.bot = bot

isocoin_system = SlashCommandGroup("isocoin", "Commands related to the IsoCoin rewards system.")

@isocoin_system.command(
name="balance",
description="See your IsoCoin balances"
)
async def isocoin_balance(self, 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"
)
@commands.cooldown(1, 86400, commands.BucketType.user)
async def isocoin_daily(self, ctx: ApplicationContext):
isocoins_reward = random.randint(2500, 5000)
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!")

@isocoin_system.command(
name="shop",
description="See all the items that you can buy using your IsoCoins."
)
async def isocoin_shop(self, ctx: ApplicationContext):
await ctx.respond("IsoCoin shop is coming soon! Check back later for new items.")

# Cog Initialization
def setup(bot): bot.add_cog(IsoCoin(bot))
32 changes: 2 additions & 30 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from discord.ext import commands
from discord.ext.commands import *
from cogs.economy import get_wallet, get_bank, new_bank, new_wallet
from cogs.isocoin import create_isocoin_key

# Slash option types:
# Just use variable types to define option types.
Expand Down Expand Up @@ -136,7 +137,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
create_isocoin_key(ctx.author.id)
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)] = {}
Expand Down Expand Up @@ -301,35 +302,6 @@ async def reload(ctx: ApplicationContext, cog: str):
await ctx.respond(embed=discord.Embed(description=f"{cog} cog successfully reloaded.", color=discord.Color.green()))
except: await ctx.respond(embed=discord.Embed(description=f"{cog} cog not found.", color=discord.Color.red()))

# 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"
)
@commands.cooldown(1, 86400, commands.BucketType.user)
async def isocoin_daily(ctx: ApplicationContext):
isocoins_reward = random.randint(2500, 5000)
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!")

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",
Expand Down