JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 68
  • Score
    100M100P100Q84376F
  • License MIT

Wrapper around Discord.js StringSelectMenu to bypass Discord's 25 option limit.

Package Exports

  • stringselectunlimited

Readme

String Select Unlimited

A wrapper around Discord.js StringSelectMenu to bypass Discord's 25 option limit by adding pagination.

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 | null Next page number
prevPageNumber number | null 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({totalItems: 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);