Skip to content

Economy - #7

Open
vmbbi wants to merge 36 commits into
masterfrom
economy
Open

Economy#7
vmbbi wants to merge 36 commits into
masterfrom
economy

Conversation

@vmbbi

@vmbbi vmbbi commented Jul 3, 2026

Copy link
Copy Markdown
Member

added gambling money etc

@vmbbi
vmbbi requested review from drtheodor and rapbattlegod32 July 3, 2026 18:38
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
@vmbbi
vmbbi requested review from drtheodor and rapbattlegod32 July 4, 2026 06:13

@drtheodor drtheodor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also no leaderboard 😔

Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread config.json.js Outdated
Comment thread config.json.js Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
@rapbattlegod32

Copy link
Copy Markdown
Member
export_1783153248310.mov

@vmbbi
vmbbi requested a review from drtheodor July 4, 2026 10:57
@rapbattlegod32

Copy link
Copy Markdown
Member

are we adding taxes

@drtheodor drtheodor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure everything uses pings instead of plain name mentions and messages use format templates from config as other commands do

as for "could be its own function" comments, all of them could be extracted into a single function and use a single format template from the config

Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread config.json.js Outdated
@vmbbi
vmbbi requested a review from drtheodor July 5, 2026 19:41

@drtheodor drtheodor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pagination should be a separate class/method/utility thing (all for the /search trust) + it should use a more random random

Comment thread src/commands/fun/economy.ts
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/index.ts
Comment thread config.json.js Outdated

@drtheodor drtheodor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of storing all shop items in the db only store the ones that are limited amount and only store their id

all shop items should be dictated by the config and nothing else (inflation command has to go)

also make sure inventory items get killed if they no longer exist in the config

@vmbbi
vmbbi requested a review from drtheodor July 10, 2026 05:14
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
@vmbbi
vmbbi requested a review from rapbattlegod32 July 24, 2026 17:22
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/commands/fun/economy.ts Outdated
Comment thread src/util/paginator2.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new “economy” feature set (balances, shop/inventory, wages, and gambling) for the Discord bot, adds an embed-based button paginator utility, and updates the wiki search command to return paginated embeds instead of multi-message text output.

Changes:

  • Added a new /economy command with balance, shop, inventory, wages, admin adjustments, and gambling subcommands (including roulette threads).
  • Added src/util/paginator2.ts for interactive embed pagination (Prev/Next buttons).
  • Updated the support wiki search command to build paginated embeds and use the new paginator; extended config.json.js with economy configuration/messages.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/util/paginator2.ts New interactive embed pagination utility using message component buttons.
src/commands/support/search.ts Converts wiki search output into paginated embeds using the new paginator.
src/commands/fun/economy.ts Adds the economy command implementation (DB models + shop/wages/gambling flows).
config.json.js Adds economy config (shop items, permissions, and user-facing messages).
Comments suppressed due to low confidence (6)

src/commands/fun/economy.ts:128

  • The EconomyProfile↔Inventory association uses only userId as the foreign/target key, ignoring guildId. Since EconomyProfile has a composite primary key (guildId+userId), this association can’t be represented correctly and may create invalid/incorrect foreign key constraints and cross-guild joins.
        EconomyProfile.hasMany(Inventory, { foreignKey: "userId", sourceKey: "userId", onDelete: "CASCADE" });
        Inventory.belongsTo(EconomyProfile, { foreignKey: "userId", targetKey: "userId" });

src/commands/fun/economy.ts:685

  • newBalance is derived as userProfile.balance - totalCost after calling userProfile.decrement(...). Depending on Sequelize dialect/behavior, userProfile.balance may already reflect the decremented value, which would double-subtract the cost and report the wrong remaining balance.
            await userProfile.decrement({ balance: totalCost }, { transaction: t });
            newBalance = userProfile.balance - totalCost;

src/commands/fun/economy.ts:738

  • The setTimeout(..., msRemaining) for temp roles can exceed Node’s maximum timeout (~2,147,483,647ms). With durationDays: 30 in config, this overflows and can fire immediately/early, removing roles prematurely. Expiration is already handled by the TempRole sweeper in setup(), so this timer is both risky and redundant.
                const msRemaining = item.durationDays * 24 * 60 * 60 * 1000;
                const memberRef = interaction.member;
                const targetRoleId = item.roleId;
                const targetGuildId = interaction.guildId!;
                const targetUserId = interaction.user.id;

config.json.js:213

  • Shop messages have formatting/placeholder issues: soldOut uses ${name} (won’t be substituted by format()), cantAfford has an extra leading backtick and is missing a closing backtick, and successBuy uses $${balance} which will render as a double $ and won’t substitute cleanly.
      soldOut: "❌ Sorry, **${name}** is completely sold out!",
      cantAfford: "`❌ You can't afford that! **{name}** costs \`${price}\`, but you only have \`${balance}\`.",
      successBuy: "🎉 Successfully bought **{name}** for \`${price}\`{message}. Your remaining balance is \`$${balance}\`.",

config.json.js:261

  • wages.message uses ${salary} / ${balance} placeholders, but the bot uses format() with {salary} / {balance}. This will show the placeholders literally in Discord.
    wages: {
      message: "{emoji} You worked a hard shift and claimed your wage of **${salary}**!\n🏦 **New Balance:** ${balance}",
      defaultAmount: 0,
      roleSalaries: {

src/commands/fun/economy.ts:761

  • If granting the role fails, the code claims the user was refunded but only refunds when profile was found before the transaction. If the profile didn’t exist initially, profile is null and no refund happens even though the purchase already decremented the DB balance.
        } catch (error) {
            console.error("Failed to assign shop role:", error);
            if (profile) {
                profile.balance += totalCost;
                await profile.save();
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/util/paginator2.ts
Comment thread src/commands/support/search.ts Outdated
Comment thread src/commands/fun/economy.ts
Comment thread config.json.js
rapbattlegod32 and others added 4 commits July 26, 2026 17:08
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants