1.0.1 • Published 1 year ago

@timjuice/discordjs-pagination v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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

1 year ago

1.0.0

1 year ago