Skip to content

Instantly share code, notes, and snippets.

@y21
Created September 8, 2020 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y21/77ea73068edd949aa23386f5d22c1692 to your computer and use it in GitHub Desktop.
Save y21/77ea73068edd949aa23386f5d22c1692 to your computer and use it in GitHub Desktop.
pagination w editOrReply
const { Paginator } = require('detritus-pagination');
const { ShardClient } = require('detritus-client');
const client = new ShardClient('token');
const paginator = new Paginator(client, {
maxTime: 300000,
// ...
});
// Wrapper function
function createReactionPaginator(response, data = {}) {
return paginator.createReactionPaginator({
commandMessage: response,
...data
});
}
/* somewhere in a command or whatever */
const pages = ['hello', 'this is page 2'];
const response = await ctx.editOrReply(pages[0]);
// use custom `createReactionPaginator` instead of directy calling paginator.createReactionPaginator
await createReactionPaginator(response, {
pages,
message: ctx.message
});
/* ---- */
await client.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment