npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unb-api

v1.4.0

Published

API wrapper for UnbelievaBoat Discord Bot API

Downloads

714

Readme

UnbelievaBoat API

Discord npm npm downloads Open Source Love NPM

Installation

npm install unb-api

Documentation

Full API documentation is located at https://unbelievaboat.com/api/docs

Example

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));

Constructor

new Client(token, [options])

Options

| Type | Property | Description | |--------|---------------|--------------------------------------------------------------------------------| | String | baseURL? | API hostname. Defaults to https://unbelievaboat.com/api | | Number | version? | API version. Defaults to the latest version | | Number | maxRetries? | Maximum number of times to retry a request if it's rate-limited. Defaults to 3 |

Methods

Economy

getUserBalance(guildId: string, userId: string)
Returns: Promise<User>

setUserBalance(guildId: string, userId: string, balance: Balance, reason?: string)
Returns: Promise<User>

editUserBalance(guildId: string, userId: string, balance: Balance, reason?: string)
Returns: Promise<User>

getGuildLeaderboard(guildId: string, query?: ListOptions)
Returns: Promise<User[]> | Promise<{ users: User[], totalPages: number }>

[!NOTE]
If the query for getGuildLeaderboard 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)
Returns: Promise<Guild>

getApplicationPermission(guildId: string)
Returns: Promise<Permission>

Items

getItems(guildId: string, options?: ListOptions)
Returns: Promise<{ page: number, totalPages: number, items: StoreItem[] }>

getItem(guildId: string, itemId: string)
Returns: Promise<StoreItem>

createItem(guildId: string)
Returns: Promise<StoreItem>

editItem(guildId: string, itemId: string, data: StoreItem | object, options?: { cascadeUpdate?: boolean })
Returns: Promise<StoreItem>

deleteItem(guildId: string, itemId: string)
Returns: Promise<any>

getInventoryItems(guildId: string, userId: string, options?: ListOptions)
Returns: Promise<{ page: number, totalPages: number, items: InventoryItem[] }>

getInventoryItem(guildId: string, userId: string, itemId: string)
Returns: Promise<InventoryItem>

addInventoryItem(guildId: string, userId: string, itemId: string, quantity?: string | number, options?: { inventoryUserId?: string })
Returns: Promise<InventoryItem>

removeInventoryItem(guildId: string, userId: string, itemId: string, quantity?: string | number)
Returns: Promise<any>

ListOptions Parameters

| Type | Property | |----------|-----------| | String[] | sort? | | Number | limit? | | Number | offset? | | Number | page? |

Structures

User

| Type | Property | Description | |--------|-----------|--------------------------------------------------------------------------------------------------| | Number | rank? | Leaderboard rank of the user. This is only present on getUserBalance() and getGuildLeaderboard() | | String | user_id | User ID of the discord user. | | Number | cash | User's cash balance. | | Number | bank | User's bank balance. | | Number | total | User's total balance. |

Guild

| Type | Property | Description | |--------|------------------|--------------------------| | String | id | Guild ID. | | String | name | Guild name. | | Number | icon | Icon hash. | | Number | iconURL | Icon url. | | String | ownerID | User ID of the owner. | | Number | memberCount | Total number of members. | | String | currencySymbol | Currency symbol |

StoreItem

| Type | Property | Description | |---------|------------------|---------------------------------------------------------------------------| | String | id | Unique ID of the item in the store. | | String | name | Name of the item. | | String | description? | Description of the item. | | Number | price | Price of the item. | | Number | stockRemaining | Amount of stock remaining for the item. | | Boolean | unlimitedStock | Whether the item has unlimited stock. | | Boolean | isInventory | Indicates if the item will be added to a user’s inventory when purchased. | | Date | expiresAt? | Expiration date of the item. | | Boolean | isUsable | Whether the item can be used by the user. | | Boolean | isSellable | Whether the item can be sold by the user. | | Array | requirements | Requirements needed to purchase the item. | | Array | actions | Actions performed when the item is used. | | String | emojiUnicode? | Unicode emoji associated with the item. | | String | emojiId? | Custom emoji ID associated with the item. |

InventoryItem

| Type | Property | Description | |-------------------------------------------------|-----------------|-----------------------------------------------| | String | itemId | Unique ID of the item in the inventory. | | Number | quantity | Quantity of the item in the user's inventory. | | String | name | Name of the item. | | String | description? | Description of the item. | | Boolean | isUsable | Whether the item can be used by the user. | | Boolean | isSellable | Whether the item can be sold by the user. | | StoreItemRequirement[] | requirements | Requirements needed to use the item. | | StoreItemAction[] | actions | Actions performed when the item is used. | | String | emojiUnicode? | Unicode emoji associated with the item. | | String | emojiId? | 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. | | StoreItemRequirementMatchType | matchType | Specifies how the requirement must be met. Can be EVERY, AT_LEAST_ONE, or NONE. | | String[] | ids | An array of IDs that correspond to roles, items, or other required entities. | | Number | balance | 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. | | String[] | ids | An array of IDs corresponding to roles, items, or other entities involved in the action. | | Object | message? | Discord message object, only applicable if type is RESPOND. | | Number | balance? | 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. | | String | json | JSON representation of the allowed and denied permissions. |

Support

Discord Server