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
68 changes: 68 additions & 0 deletions cogs/devtools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Imports
import discord
import os
from framework.isobot.currency import CurrencyAPI
from framework.isobot.db import levelling
from discord import option, ApplicationContext, SlashCommandGroup
from discord.ext import commands

# Variables
client_data_dir = f"{os.path.expanduser('~')}/.isobot"

# Framework Module Initialization
currency = CurrencyAPI(f"{client_data_dir}/database/currency.json", f"{client_data_dir}/logs/currency.log")
levelling = levelling.Levelling()

# Bot Superusers List
superusers = ["738290097170153472"]

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

devtools = SlashCommandGroup("devtools", "Developer-only configuration commands for the bot.")

@devtools.command(
name='modify_balance',
description="Modifies user balance (Normal Digit: Adds Balance; Negative Digit: Removes Balance)"
)
@option(name="user", description="Specify the user to change their balance", type=discord.User)
@option(name="modifier", description="Specify the balance to modify", type=int)
async def modify_balance(self, ctx: ApplicationContext, user: discord.User, modifier: int):
if str(ctx.author.id) not in superusers: return ctx.respond("This command is usable only by **developers** and **bot superusers**.", ephemeral=True)
try:
currency.add(user.id, modifier)
await ctx.respond(f"{user.name}\'s balance has been modified by {modifier} coins.\n\n**New Balance:** {currency.get_wallet(user.id)} coins", ephemeral=True)
except KeyError: await ctx.respond("That user doesn't exist in the database.", ephemeral=True)

@devtools.command(
name="edit_rank",
description="Edits a user's rank."
)
@option(name="user", description="Who's rank do you want to edit?", type=discord.User)
@option(name="new_rank", description="The new rank you want to set for the user", type=int)
async def edit_rank(self, ctx: ApplicationContext, user: discord.User, new_rank: int):
if str(ctx.author.id) not in superusers: return await ctx.respond("This command is usable only by **developers** and **bot superusers**.", ephemeral=True)
try:
levelling.set_level(user.id, new_rank)
await ctx.respond(f"{user.display_name}\'s rank successfully edited. `New Rank: {levelling.get_level(user.id)}`")
except KeyError: return await ctx.respond("That user isn't indexed yet.", ephemeral=True)

@devtools.commands(
name="edit_xp",
description="Edits a user's XP."
)
@option(name="user", description="Who's rank do you want to edit?", type=discord.User)
@option(name="new_xp", description="The new xp count you want to set for the user", type=int)
async def edit_xp(self, ctx: ApplicationContext, user: discord.User, new_xp: int):
if str(ctx.author.id) not in superusers: return await ctx.respond("This command is usable only by **developers** and **bot superusers**.", ephemeral=True)
try:
levelling.set_xp(user.id, new_xp)
await ctx.respond(f"{user.display_name}\'s XP count successfully edited. `New XP: {levelling.get_xp(user.id)}`")
except KeyError: return await ctx.respond("That user isn't indexed yet.", ephemeral=True)


# Initialization
def setup(bot):
bot.add_cog(DevTools(bot))
13 changes: 0 additions & 13 deletions cogs/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,19 +399,6 @@ async def gift(self, ctx: ApplicationContext, user:discord.User, item:str, amoun
utils.logger.error(e)
await ctx.respond(f"wtf is {item}?")

@commands.slash_command(
name='modify_balance',
description="Modifies user balance (Normal Digit: Adds Balance; Negative Digit: Removes Balance)"
)
@option(name="user", description="Specify the user to change their balance", type=discord.User)
@option(name="modifier", description="Specify the balance to modify", type=int)
async def modify_balance(self, ctx: ApplicationContext, user:discord.User, modifier:int):
if ctx.author.id != 738290097170153472: return ctx.respond("Sorry, but this command is only for my developer's use.", ephemeral=True)
try:
currency.add(user.id, modifier)
await ctx.respond(f"{user.name}\'s balance has been modified by {modifier} coins.\n\n**New Balance:** {currency.get_wallet(user.id)} coins", ephemeral=True)
except KeyError: await ctx.respond("That user doesn't exist in the database.", ephemeral=True)

@commands.slash_command(
name='give',
description='Gives any amount of cash to someone else'
Expand Down
26 changes: 0 additions & 26 deletions cogs/levelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,6 @@ async def rank(self, ctx: ApplicationContext, user: discord.User=None):
await ctx.respond(embed=localembed)
except KeyError: return await ctx.respond("Looks like that user isn't indexed yet. Try again later.", ephemeral=True)

@commands.slash_command(
name="edit_rank",
description="Edits a user's rank. (DEV ONLY)"
)
@option(name="user", description="Who's rank do you want to edit?", type=discord.User)
@option(name="new_rank", description="The new rank you want to set for the user", type=int)
async def edit_rank(self, ctx: ApplicationContext, user: discord.User, new_rank: int):
if ctx.author.id != 738290097170153472: return await ctx.respond("This command isn't for you.", ephemeral=True)
try:
levelling.set_level(user.id, new_rank)
await ctx.respond(f"{user.display_name}\'s rank successfully edited. `New Rank: {levelling.get_level(user.id)}`")
except KeyError: return await ctx.respond("That user isn't indexed yet.", ephemeral=True)

@commands.slash_command(
name="edit_xp",
description="Edits a user's XP. (DEV ONLY)"
)
@option(name="user", description="Who's rank do you want to edit?", type=discord.User)
@option(name="new_xp", description="The new xp count you want to set for the user", type=int)
async def edit_xp(self, ctx: ApplicationContext, user: discord.User, new_xp: int):
if ctx.author.id != 738290097170153472: return await ctx.respond("This command isn't for you.", ephemeral=True)
try:
levelling.set_xp(user.id, new_xp)
await ctx.respond(f"{user.display_name}\'s XP count successfully edited. `New XP: {levelling.get_xp(user.id)}`")
except KeyError: return await ctx.respond("That user isn't indexed yet.", ephemeral=True)

@commands.slash_command(
name="leaderboard_levels",
description="View the global leaderboard for user levelling ranks."
Expand Down
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ async def credits(ctx: ApplicationContext):
"fun",
"utils",
"afk",
"devtools",
# "osu", Disabled due to ossapi library metadata issues. (will probably remove osu cog anyway, because cog code is outdated with ossapi library)
"weather",
"isocard"
Expand Down