Skip to content

Commit

Permalink
Use unicode codepoints and rename PageUtils > PageHelper
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Castle <[email protected]>
  • Loading branch information
Kas-tle committed Sep 16, 2024
1 parent 2fec219 commit 1c00515
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.geysermc.discordbot.util.BotColors;
import org.geysermc.discordbot.util.DocSearchResult;
import org.geysermc.discordbot.util.MessageHelper;
import org.geysermc.discordbot.util.PageUtils;
import org.geysermc.discordbot.util.PageHelper;
import org.geysermc.discordbot.util.PropertiesManager;

import java.net.URLEncoder;
Expand Down Expand Up @@ -111,7 +111,7 @@ protected void execute(SlashCommandEvent event) {
return;
}

new PageUtils(embeds, event, -1);
new PageHelper(embeds, event, -1);
});

}
Expand All @@ -138,7 +138,7 @@ protected void execute(CommandEvent event) {
return;
}

new PageUtils(embeds, event, -1);
new PageHelper(embeds, event, -1);
});
}

Expand Down Expand Up @@ -267,7 +267,7 @@ private String getDescriptionFieldBody(DocSearchResult result, String query, int
int lastLine = -1;
for (int i : includedLines) {
if (lastLine != -1 && i - lastLine > 1) {
description += "**•••**\n";
description += "**\u2022\u2022\u2022**\n";
}

description += "> " + lines.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package org.geysermc.discordbot.util;

import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.entities.MessageEmbed;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.command.SlashCommandEvent;
Expand All @@ -48,7 +49,7 @@
/**
* A utility class for paginating through a list of embeds using buttons in Discord JDA.
*/
public class PageUtils {
public class PageHelper {

private final Map<String, Integer> pages;
private final List<MessageEmbed> embeds;
Expand All @@ -64,7 +65,7 @@ public class PageUtils {
* @param event The SlashCommandEvent.
* @param time The time in milliseconds before the paginator expires (default is 5 minutes).
*/
public PageUtils(
public PageHelper(
List<MessageEmbed> embeds,
SlashCommandEvent event,
long time
Expand Down Expand Up @@ -99,10 +100,10 @@ public PageUtils(
* Constructor for Message-based Commands.
*
* @param embeds The list of embeds to paginate through.
* @param event The CommandEvent from your command framework.
* @param event The CommandEvent.
* @param time The time in milliseconds before the paginator expires (default is 5 minutes).
*/
public PageUtils(
public PageHelper(
List<MessageEmbed> embeds,
CommandEvent event,
long time
Expand Down Expand Up @@ -140,8 +141,8 @@ private Collection<? extends ItemComponent> getRow() {
boolean isFirstPage = currentPage == 0;
boolean isLastPage = currentPage == embeds.size() - 1;

Button prevButton = Button.secondary("prev_page", "⏮️").withDisabled(isFirstPage);
Button nextButton = Button.secondary("next_page", "⏭️").withDisabled(isLastPage);
Button prevButton = Button.secondary("prev_page", Emoji.fromUnicode("\u23ee")).withDisabled(isFirstPage);
Button nextButton = Button.secondary("next_page", Emoji.fromUnicode("\u23ed")).withDisabled(isLastPage);

return ActionRow.of(prevButton, nextButton).getActionComponents();
}
Expand Down

0 comments on commit 1c00515

Please sign in to comment.