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:

Parameter
Type
Required
Description

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 found

  • Item out of stock

  • User not found

  • Insufficient funds

  • Requires level X

  • Requires prestige X

  • Purchase limit reached

  • You 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

Category
Emoji
Typical Use

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