gamemax.paginator
v1.0.6
Published
💜 Plugin for easy creation and interaction with pages
Downloads
2
Maintainers
Readme
♻️ 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 theexecute
parameter you want something to be displayed in the console. We indicate callback inexecute
exampletext
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 contentadd
- Returns a string (or writing). Fires when using the<page>.add()
functionupdate
- Will return the object on page refreshselect
- Returns an object containing the page you selected and its content.end
- Returnstrue
if everything worked successfully