Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for error message in jumping pages by input #54

Open
officialakhil opened this issue Jan 27, 2021 · 0 comments
Open

Option for error message in jumping pages by input #54

officialakhil opened this issue Jan 27, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@officialakhil
Copy link

officialakhil commented Jan 27, 2021

Hey there! Was just trying this library out and wondering how would I handle a case where user inputs a page number that doesn't exist.

Example: I have pagination of 5 embeds and a reaction emoji which prompts the user for a page number ( using .setClientAssets for a custom prompt message). I want to handle the case where the user enters a number like 6...

Here is my code

      const embeds = [];
      for (let i = 1; i <= 5; ++i) {
        embeds.push(new Discord.MessageEmbed().addField('Page', i));
      }
      const Embeds = new PaginationEmbed.Embeds()
        .setArray(embeds)
        .setAuthorizedUsers([message.author.id])
        .setChannel(message.channel)
        .setPageIndicator(true)
        .setTitle('Test Title')
        .setDescription('Test Description')
        .setFooter('Test Footer Text')
        .setURL('https://gazmull.github.io/discord-paginationembed')
        .setColor(0xFF00AE)
        .setTimeout(60000)
        .setClientAssets({ prompt: 'Page plz {{user}}' })
        .setDeleteOnTimeout(true)
        .setFunctionEmojis({
          '⬆': (_, instance) => {
            for (const embed of instance.array)
              embed.fields[0].value++;
          },
          '⬇': (_, instance) => {
            for (const embed of instance.array)
              embed.fields[0].value--;
          }
        })
        .on('start', () => console.log('Started!'))
        .on('finish', (user) => console.log(`Finished! User: ${user.username}`))
        .on('react', (user, emoji) => console.log(`Reacted! User: ${user.username} | Emoji: ${emoji.name} (${emoji.id})`))
        .on('expire', () => console.warn('Expired!'))
        .on('error', (error) => {
          console.log(error);
        });
      
      await Embeds.build();

The error doesn't actually come at .on('error', ...) listener

@gazmull gazmull added the enhancement New feature or request label Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants