New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

discord-msg-pagination

Package Overview
Dependencies
Maintainers
0
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-msg-pagination

A pagination utility for Messages in discord.js using message components

  • 2.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Discord Message Pagination

Discord Message Pagination is an addon for Discord.js. It helps you to create paginated messages using slash commands and message components (Buttons) if your content is too long for one message.

Installation

Node.js v16.6.0 or newer is required.

npm install discord-msg-pagination

Optional packages

  • discord-embed-colors to easily convert hex colors to decimal numbers used in discord embeds

Usage

Quick start using embed array

import { sendPaginatedEmbed } from 'discord-msg-pagination';

sendPaginatedEmbed(interaction, embeds);

Using a custom function to update message embed dynamically

onPageChange will be called whenever a button interaction happens.

import { sendPaginatedEmbed } from 'discord-msg-pagination';

function onPageChange(pageNumber, embed) {
  return embed
    .setTitle(`This is page #${pageNumber}`);
}

sendPaginatedEmbed(interaction, initialEmbed, { onPageChange });

Options

interface Options {
  /**
   * Text to be displayed on next button
   */
  nextLabel?: string,
  /**
   * Text to be displayed on previous button
   */
  previousLabel?: string,
  /**
   * How long the buttons will work (defaults to 10min)
   */
  time?: number,
  /**
   * Button style
   */
  style?: ButtonStyle,
  /**
   * Function which will run if the page changed. Only if second argument is not an array. 
   */
  onPageChange?: (event: 'next' | 'previous' | string, embed: EmbedBuilder) => EmbedBuilder | Promise<EmbedBuilder>,
  /**
   * Message content
   */
  content?: string,
  /**
   * Add custom components to render above the pagination buttons
   */
  components?: ActionRowBuilder<any>[],
  /**
   * Specifiy a restriction for pagination buttons
   */
  restriction?: 'ALL' | 'AUTHOR' | ((member: GuildMember) => boolean | Promise<boolean>),
  /**
   * Set a start index. Default index is 0
   */
  startIndex?: number,  
  /**
   * Send ephemeral response
   */
  ephemeral?: boolean
}

Local test

Set your DISCORD_BOT_TOKEN to your .env.

cp .env.sample .env

npm run test:bot

Keywords

FAQs

Package last updated on 06 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc