Package Exports
- stringselectunlimited
- stringselectunlimited/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stringselectunlimited) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
String Select Unlimited
A wrapper around Discord.js StringSelectMenu to bypass Discord's 25 option limit by
adding pagination.
- Used by Pokecord++ and Audicy Discord bots.
- Discord Server
Install
npm install stringselectunlimited
Usage
Constructor
StringSelectUnlimited(options : StringSelectMenuOptions)
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
pageMetadata |
PageData | Additional data to stringify along with page option | no | { emoji: {}, data: {} } |
totalItems |
number | Total number of items | no | 0 |
page |
number | Initial page number | no | 1 |
Methods
| Method | Parameters | Description |
|---|---|---|
goto |
page: number | Navigate to specific page |
Setters
| Method | Parameters | Description |
|---|---|---|
setPageMetadata |
metadata: PageData | Update page metadata |
setTotalItems |
total: number | Update total items |
Getters
| Method | Returns | Description |
|---|---|---|
pageMetadata |
PageData | Page Metadata |
currentPageNumber |
number | Current page number |
totalPageNumber |
number | Total number of pages |
nextPageNumber |
number | Next page number |
prevPageNumber |
number | Previous page number |
pageSize |
number | Menu size excluding page options |
Examples
Dynamic Pagination
import axios from 'axios';
import {ActionRowBuilder} from 'discord.js';
import {StringSelectUnlimited} from 'StringSelectUnlimited';
const menu = new StringSelectUnlimited().setTotalItems(500);
const limit = menu.pageSize;
const offset = limit * (menu.currentPageNumber - 1);
const {data} = await axios.get(`https://example.com/api/data`, {params: {limit, offset}});
menu.setOptions(
data.map(d => ({label: d.title, value: String(d.id)})
));
return new ActionRowBuilder().addComponents(menu);Preloaded Pagination
import {ActionRowBuilder} from 'discord.js';
import {StringSelectUnlimited} from 'StringSelectUnlimited';
const data = [{label: 'Example', value: '1'}]; // large array
const menu = new StringSelectUnlimited().setOptions(data);
return new ActionRowBuilder().addComponents(menu);