API wrapper for UnbelievaBoat Discord Bot API
npm install unb-api




npm install unb-api
Full API documentation is located at https://unbelievaboat.com/api/docs
``javascript
const { Client } = require('unb-api');
const client = new Client('TOKEN'); // Get your API token from https://unbelievaboat.com/api/docs
const guildID = '305129477627969547';
const userID = '261674810914897931';
client.getUserBalance(guildID, userID).then(user => console.log(user));
client.getGuildLeaderboard(guildID, { sort: 'cash' }).then(lb => console.log(lb));
`
new Client(token, [options])
##### Options
| Type | Property | Description |
|--------|---------------|--------------------------------------------------------------------------------|
| String | baseURL? | API hostname. Defaults to https://unbelievaboat.com/api |version?
| Number | | API version. Defaults to the latest version |maxRetries?
| Number | | Maximum number of times to retry a request if it's rate-limited. Defaults to 3 |
#### Economy
getUserBalance(guildId: string, userId: string) Promise
Returns:
setUserBalance(guildId: string, userId: string, balance: Balance, reason?: string) Promise
Returns:
editUserBalance(guildId: string, userId: string, balance: Balance, reason?: string) Promise
Returns:
getGuildLeaderboard(guildId: string, query?: ListOptions) Promise
Returns: getGuildLeaderboard
> [!NOTE]
> If the query for includes a page parameter, the response will be an object containing both users and totalPages.
> Otherwise, it will return a simple array of User[].
#### Generic
getGuild(guildId: string) Promise
Returns:
getApplicationPermission(guildId: string) Promise
Returns:
#### Items
getItems(guildId: string, options?: ListOptions) Promise<{ page: number, totalPages: number, items: StoreItem[] }>
Returns:
getItem(guildId: string, itemId: string) Promise
Returns:
createItem(guildId: string) Promise
Returns:
editItem(guildId: string, itemId: string, data: StoreItem | object, options?: { cascadeUpdate?: boolean }) Promise
Returns:
deleteItem(guildId: string, itemId: string) Promise
Returns:
getInventoryItems(guildId: string, userId: string, options?: ListOptions) Promise<{ page: number, totalPages: number, items: InventoryItem[] }>
Returns:
getInventoryItem(guildId: string, userId: string, itemId: string) Promise
Returns:
addInventoryItem(guildId: string, userId: string, itemId: string, quantity?: string | number, options?: { inventoryUserId?: string }) Promise
Returns:
removeInventoryItem(guildId: string, userId: string, itemId: string, quantity?: string | number) Promise
Returns:
##### ListOptions Parameters
| Type | Property |
|----------|-----------|
| String[] | sort? |limit?
| Number | |offset?
| Number | |page?
| Number | |
#### User
| Type | Property | Description |
|--------|-----------|--------------------------------------------------------------------------------------------------|
| Number | rank? | Leaderboard rank of the user. This is only present on getUserBalance() and getGuildLeaderboard() |user_id
| String | | User ID of the discord user. |cash
| Number | | User's cash balance. |bank
| Number | | User's bank balance. |total
| Number | | User's total balance. |
#### Guild
| Type | Property | Description |
|--------|------------------|--------------------------|
| String | id | Guild ID. |name
| String | | Guild name. |icon
| Number | | Icon hash. |iconURL
| Number | | Icon url. |ownerID
| String | | User ID of the owner. |memberCount
| Number | | Total number of members. |currencySymbol
| String | | Currency symbol |
#### StoreItem
| Type | Property | Description |
|---------|------------------|---------------------------------------------------------------------------|
| String | id | Unique ID of the item in the store. |name
| String | | Name of the item. |description?
| String | | Description of the item. |price
| Number | | Price of the item. |stockRemaining
| Number | | Amount of stock remaining for the item. |unlimitedStock
| Boolean | | Whether the item has unlimited stock. |isInventory
| Boolean | | Indicates if the item will be added to a user’s inventory when purchased. |expiresAt?
| Date | | Expiration date of the item. |isUsable
| Boolean | | Whether the item can be used by the user. |isSellable
| Boolean | | Whether the item can be sold by the user. |requirements
| Array | | Requirements needed to purchase the item. |actions
| Array | | Actions performed when the item is used. |emojiUnicode?
| String | | Unicode emoji associated with the item. |emojiId?
| String | | Custom emoji ID associated with the item. |
#### InventoryItem
| Type | Property | Description |
|-------------------------------------------------|-----------------|-----------------------------------------------|
| String | itemId | Unique ID of the item in the inventory. |quantity
| Number | | Quantity of the item in the user's inventory. |name
| String | | Name of the item. |description?
| String | | Description of the item. |isUsable
| Boolean | | Whether the item can be used by the user. |isSellable
| Boolean | | Whether the item can be sold by the user. |requirements
| [StoreItemRequirement[]](#StoreItemRequirement) | | Requirements needed to use the item. |actions
| [StoreItemAction[]](#StoreItemAction) | | Actions performed when the item is used. |emojiUnicode?
| String | | Unicode emoji associated with the item. |emojiId?
| String | | Custom emoji ID associated with the item. |
#### StoreItemRequirement
| Type | Property | Description |
|-------------------------------|-------------|---------------------------------------------------------------------------------------|
| StoreItemRequirementType | type | Type of requirement. Could be one of ROLE, TOTAL_BALANCE, or ITEM. |matchType
| StoreItemRequirementMatchType | | Specifies how the requirement must be met. Can be EVERY, AT_LEAST_ONE, or NONE. |ids
| String[] | | An array of IDs that correspond to roles, items, or other required entities. |balance
| Number | | Minimum balance required (applicable if type is TOTAL_BALANCE). |
#### StoreItemAction
| Type | Property | Description |
|---------------------|------------|------------------------------------------------------------------------------------------------------------------------------------------|
| StoreItemActionType | type | Type of action. Could be one of RESPOND, ADD_ROLES, REMOVE_ROLES, ADD_BALANCE, REMOVE_BALANCE, ADD_ITEMS, or REMOVE_ITEMS. |ids
| String[] | | An array of IDs corresponding to roles, items, or other entities involved in the action. |message?
| Object | | Discord message object, only applicable if type is RESPOND. |balance?
| Number | | Balance amount to be added or removed (applicable if type is ADD_BALANCE or REMOVE_BALANCE). |
#### Permission
| Type | Property | Description |
|--------|----------|------------------------------------------------------------|
| Number | allow | The allowed bitwise permissions number. |json` | JSON representation of the allowed and denied permissions. |
| String |