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
48 changes: 23 additions & 25 deletions cogs/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,31 +642,29 @@ async def treasury(self, ctx: ApplicationContext):
description="View the global leaderboard for net worth."
)
async def leaderboard_nw(self, ctx: ApplicationContext):
await ctx.respond("This command is currently disabled due to an internal issue. I apologize for the inconvenience.", ephemeral=True)
#await ctx.defer()
#nw_dict = dict()
#for person in currency["wallet"]:
# nw_dict[str(person)] = int(currency["wallet"][str(person)]) + int(currency["bank"][str(person)])
#undicted_leaderboard = sorted(nw_dict.items(), key=lambda x:x[1], reverse=True)
#dicted_leaderboard = dict(undicted_leaderboard)
#parsed_output = str()
#y = 1
#for i in dicted_leaderboard:
# if y < 10:
# try:
# if nw_dict[i] != 0:
# user_context = await discord.ext.commands.Bot.fetch_user(self, int(i))
# if not user_context.bot:
# print(i, nw_dict[i])
# if y == 1: yf = ":first_place:"
# elif y == 2: yf = ":second_place:"
# elif y == 3: yf = ":third_place:"
# else: yf = f"#{y}"
# parsed_output += f"{yf} **{user_context.name}:** {nw_dict[i]} coins\n"
# y += 1
# except discord.errors.NotFound: continue
#localembed = discord.Embed(title="Global net worth leaderboard", description=parsed_output, color=color)
#await ctx.respond(embed=localembed)
await ctx.defer()
nw_dict = dict()
for person in currency.fetch_all_cached_user_ids():
nw_dict[str(person)] = currency.get_wallet(person) + currency.get_bank(person)
undicted_leaderboard = sorted(nw_dict.items(), key=lambda x:x[1], reverse=True)
dicted_leaderboard = dict(undicted_leaderboard)
parsed_output = str()
user_count = 1
for uid in dicted_leaderboard:
if user_count < 10:
try:
if nw_dict[uid] != 0:
user_context = await ctx.bot.fetch_user(uid)
if not user_context.bot:
if user_count == 1: yf = ":first_place:"
elif user_count == 2: yf = ":second_place:"
elif user_count == 3: yf = ":third_place:"
else: yf = f"#{user_count}"
parsed_output += f"{yf} **{user_context.name}:** {nw_dict[uid]} coins\n"
user_count += 1
except discord.errors.NotFound: continue
localembed = discord.Embed(title="Global net worth leaderboard", description=parsed_output, color=color)
await ctx.respond(embed=localembed)

@commands.slash_command(
name="hack",
Expand Down
11 changes: 10 additions & 1 deletion framework/isobot/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class CurrencyAPI(Colors):
- get_user_count
- new_wallet(user)
- new_bank(user)
- delete_user(user)"""
- delete_user(user)
- fetch_all_cached_user_ids()"""

def __init__(self, db_path: str, log_path: str):
self.db_path = db_path
Expand Down Expand Up @@ -206,3 +207,11 @@ def delete_user(self, user: int) -> int:
f.write(f'{self.get_time()} framework.isobot.currency User({user}): Successfully deleted all user data from currency database.\n')
f.close()
return 0

def fetch_all_cached_user_ids(self) -> list:
"""Fetches the ids of all cached users in the currency database, and returns it as a `list`.\n\n(uses database's `wallet` property to fetch ids)"""
currency = self.load()
all_user_ids = list()
for uid in currency["wallet"]:
all_user_ids.append(str(uid))
return all_user_ids