Closed avurro closed 3 years ago
Could you show me how you're doing it? Also, what kind of issues are you having?
Only the first page appears, the buttons do not appear. Code follows:
List<Page> pages = new ArrayList<>();
for (Entry<String, List<Class<?>>> page : this.commandsCategory.entrySet())
pages.add(makePage(event, page.getKey(), page.getValue()));
event.getChannel().sendMessage((Message) pages.get(0).getContent()).queue(success -> {
Pages.paginate(success, pages, 60, TimeUnit.SECONDS);
});
private Page makePage(MessageReceivedEvent event, String category, List<Class<?>> commandsClasses) {
MessageBuilder eb = new MessageBuilder();
eb.setContent("text");
return new Page(PageType.TEXT, eb.build());
}
In Main:
public static void main(String[] args){
...
try {
jda = JDABuilder.createLight(getBottoken(), GatewayIntent.GUILD_MESSAGES)
.addEventListeners(new MessageListener())
.build();
jda.awaitReady();
Pages.activate(jda);
} catch (LoginException e) {
...
Can you please just write me a complete working piece of code?
Your code is correct, do you get any error in the console? If you use EmbedBuilder instead of MessageBuilder does it work?
Same result with EmbedBuilder. Can you please just write me a complete working piece of code that I can copy and paste?
Does this work? Please check the console for any error.
List<Page> pages = new ArrayList<>();
EmbedBuilder eb = new EmbedBuilder();
for (int i = 0; i < 5; i++) {
eb.setDescription("Test " + i);
pages.add(new Page(PageType.EMBED, eb.build()));
}
event.getChannel().sendMessage((MessageEmbed) pages.get(0).getContent()).queue(s -> {
Pages.paginate(s, pages, 60, TimeUnit.SECONDS);
});
Are you sure your code works?
Can you try it yourself please?
It does work, I use it exactly like that in my bot's code, are you sure you have all the required permissions? Could you please check if no exception were thrown in the console?
No exceptions are thrown, it just doesn't work. Can you show me how you set up JDA?
are you sure you have all the required permissions?
My bot has admin permissions
I finally understood what the problem is, the bot must have the following explicit intentions:
GatewayIntent.GUILD_MESSAGES
GatewayIntent.GUILD_MESSAGE_REACTIONS
I am using JDABuilder.createLight
and these permissions are not set by default as is the case with JDABuilder.createDefault
which is what you probably use.
You should make this explicit in the documentation.
Honesty I didn't know createLight removed such basic intents, I'll add a note about it next to required permissions. Thanks for pointing out the solution.
Checklist
Make sure that you've checked all the items below.
Library info
What libraries versions are you using.
Describe the bug
I can't in any way to make the pagination. Not even copying and pasting the code in README. Could you please write me a complete whole code?
Expected behavior
A complete sample code that I can copy and paste