Skip to content

nevzorl/gamemax-paginator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Lightweight and very smooth page builder for your bots (discord.js)
Check out plugin initialization and configuration below!

                                                          node.js Star Discord Donate

Click on a badge to learn more.

InstallationDownloadHow to use?Customization

♻️ Plugin installation:

Plugin initialization looks like this:

const plugin = require("gamemax.paginator");

[...]

You can initialize the plugin to a global variable, which makes the plugin more accessible to you.

require("gamemax.paginator").init(<object>); // Specify your variable (object)

// After that, the plugin will be available along this path:
new <object>.paginator()

You can also change the name of the element, for example:

require("gamemax.paginator").init(<object>, "example");

// After that, the plugin will be available along this path:
new <object>.example()

❓ Example to use:

const { Pages } = require("gamemax.paginator");
const page = new Pages(message.author.id); // Collector filter.

page.add("Hello"); // You can also specify an array with text: page.add([ "Hello", "Hello 2", etc. ]);
page.create(message.channel); // send message

🔓 Plugin customization:

You can customize the plugin by adding your own emoji, functions, and custom checks.

new plugin(message.author.id, [
    { emoji: "📌", execute: (channel) => channel.send("This is custom reaction!"), imports: [message.channel] },
    { emoji: "👀", execute: (text) => console.log(text), imports: ["This text will be printed to the console."] }
    /* etc.. */
], 60000); // Collector running time in ms

And so, let's now tell you in detail what is responsible for what.

  • emoji - Emoji that will be placed and perform your further action.

  • execute - The function that will execute when you click on your 'custom' reaction.

  • imports - Required parameters to run the function. They must be in an array or you will get an error. For example, in the execute parameter you want something to be displayed in the console. We indicate callback in execute example text and in the imports we include our text ["Hello bro"]

🎉 Events

You can control user actions using our events.

let page = new Pages(message.author.id);

page.on("create", (data) => console.log(data))

Available events:

  • create - Returns an object with message and collector content

  • add - Returns a string (or writing). Fires when using the <page>.add() function

  • update - Will return the object on page refresh

  • select - Returns an object containing the page you selected and its content.

  • end - Returns true if everything worked successfully