Store API
The Store API provides a powerful interface for managing server-specific stores with customizable items, categories, and reward systems.
β¨ Features
Per-server stores β Each guild has its own store
Multiple categories β Pets, roles, boosters, titles, items, special
Reward types β Pets, roles, boosters, titles, items, custom
Requirements β Level and prestige requirements
Stock management β Limited or unlimited stock
Purchase limits β Max purchases per user
Transaction logging β Full purchase history
π Quick Start
const StoreAPI = require('./utils/economy/storeAPI');
// Add a custom item
await StoreAPI.addItem(guildId, {
name: 'VIP Role',
category: 'roles',
price: 50000,
rewardType: 'role',
rewardData: { roleId: '123456789', roleDuration: null },
emoji: 'π'
});
// Get all items in a category
const pets = await StoreAPI.getItems(guildId, 'pets');
// Purchase an item for a user
const result = await StoreAPI.purchaseItem(guildId, userId, itemId, client);
if (result.success) {
console.log(`Purchased: ${result.item.name}`);
}π¦ Methods Reference
addItem(guildId, itemData)
Add a new item to the store.
Parameters:
name
string
β
Display name of the item
description
string
β
Item description
category
string
β
Category: pets, roles, boosters, titles, items, special
price
number
β
Cost in coins
stock
number
β
Available stock (-1 = unlimited)
maxPerUser
number
β
Max purchases per user (-1 = unlimited)
enabled
boolean
β
Whether item is available (default: true)
rewardType
string
β
Type of reward (see Reward Types)
rewardData
object
β
Reward-specific data
requirements
object
β
{ level: number, prestige: number }
emoji
string
β
Display emoji (default: π)
color
string
β
Hex color (default: #5865F2)
featured
boolean
β
Show in featured section
sortOrder
number
β
Sort priority (lower = first)
removeItem(guildId, itemId)
Remove an item from the store.
updateItem(guildId, itemId, updates)
Update an existing item.
getItem(guildId, itemId)
Get a single item by ID.
getItems(guildId, category?)
Get all items, optionally filtered by category.
getCategories(guildId)
Get all categories that have items.
getFeaturedItems(guildId)
Get all featured items.
purchaseItem(guildId, userId, itemId, client)
Process a purchase. Handles balance deduction, requirements validation, stock management, and reward application.
Possible Errors:
Item not foundItem out of stockUser not foundInsufficient fundsRequires level XRequires prestige XPurchase limit reachedYou already own this pet!
getUserPurchases(guildId, userId)
Get a user's purchase history.
π Reward Types
pet
Adds a pet to the user's collection.
role
Grants a Discord role to the user.
booster
Activates a temporary multiplier booster.
title
Unlocks a display title for the user.
item
Adds a generic item to user's inventory.
custom
For addon-handled rewards. The reward isn't automatically applied.
π Categories
pets
πΎ
Companion pets with earnings bonuses
roles
π
Discord role rewards
boosters
π
Temporary multipliers
titles
π·οΈ
Display titles/badges
items
π
Inventory items
special
β¨
Limited/seasonal items
π‘ Addon Examples
Adding Custom Shop Items
Seasonal/Limited Items
Dynamic Pricing
Purchase Announcements
π Item Schema
Full item object structure:
π Purchase Record Schema
