-
Notifications
You must be signed in to change notification settings - Fork 0
Creating books
Jasper edited this page Aug 21, 2022
·
1 revision
You can create books in two different ways.
The library knows a book is permanent because it contains a manually set ID. On the other hand, temporary books don't have an ID; rather, they use the message ID to find their respective pages.
To create a registrable permanent book, you extend the Book
class and call the super
constructor to set an ID.
public class Example extends Book {
public Example() {
// "example" will be the identifier of the book.
super("example");
// pages, rows, buttons...
build();
}
}
Then, you register it to your DiscordBooks
instance using the #registerBooks()
method.
public class Main {
public final DiscordBooks discordBooks = new DiscordBooks();
public static void main(String[] args) {
discordBooks.registerBooks(new Example());
}
}
This book will now be added to the database on every startup, and its buttons will work as long as it exists in your source.
On-the-go or temporary books are perfect if you need to generate content on the spot.
Book book = new Book()
// pages, rows, buttons...
.build();