Conversation
export_1783153248310.mov |
# Conflicts: # config.json.js
|
are we adding taxes |
drtheodor
left a comment
There was a problem hiding this comment.
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
drtheodor
left a comment
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
/economycommand with balance, shop, inventory, wages, admin adjustments, and gambling subcommands (including roulette threads). - Added
src/util/paginator2.tsfor interactive embed pagination (Prev/Next buttons). - Updated the support wiki search command to build paginated embeds and use the new paginator; extended
config.json.jswith 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
userIdas the foreign/target key, ignoringguildId. 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
newBalanceis derived asuserProfile.balance - totalCostafter callinguserProfile.decrement(...). Depending on Sequelize dialect/behavior,userProfile.balancemay 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). WithdurationDays: 30in config, this overflows and can fire immediately/early, removing roles prematurely. Expiration is already handled by the TempRole sweeper insetup(), 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:
soldOutuses${name}(won’t be substituted byformat()),cantAffordhas an extra leading backtick and is missing a closing backtick, andsuccessBuyuses$${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.messageuses${salary}/${balance}placeholders, but the bot usesformat()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
profilewas found before the transaction. If the profile didn’t exist initially,profileis 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.
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>
added gambling money etc