Created
September 8, 2020 19:11
-
-
Save y21/77ea73068edd949aa23386f5d22c1692 to your computer and use it in GitHub Desktop.
pagination w editOrReply
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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