Skip to content

DiscordJS Pagination helper class that can be used to easily display large amounts of data in embeds

Notifications You must be signed in to change notification settings

timjuic/DiscordJS-Pagination

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

DiscordJS Pagination helper class that can be used to easily display large amounts of data in embeds

Importing

npm init
npm i @timjuice/discordjs-pagination

const Pagination = require('@timjuice/discordjs-pagination')

Example usage

const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const Pagination = require('@timjuice/discordjs-pagination')

module.exports = {
   data: new SlashCommandBuilder()
      .setName('viewmembers')
      .setDescription('View all guild members'),

   async execute(interaction) {
      const { guild, member, client } = interaction;

      let allMembers = await guild.members.fetch().catch(console.error);

      /* Format the data records how you want them displayed (Must be array) */
      let allMembersFormated = allMembers.map(member => {
         return `<@${member.user.id}> - **${member.user.username}#${member.user.discriminator}**`
      })

      /* Create embed to display the data in, style it to your liking */
      const embed = new EmbedBuilder()
         .setTitle('Guild Members')
         .setFooter({ text: member.displayName, iconURL: member.displayAvatarURL({ dynamic: true }) })
         .setTimestamp()
         .setColor(client.globalConfig.botColorTheme);

      /* Create an instance of the Pagination class
         It will automatically respond to the provided interaction
      */
      new Pagination(interaction, allMembersFormated, embed, 5, true);
   }
}

Screenshot 2023-04-23 at 11 23 16

About

DiscordJS Pagination helper class that can be used to easily display large amounts of data in embeds

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published