Skip to content

Commit 3853dfe

Browse files
committed
Add date to the xkcd command
1 parent c4a3df0 commit 3853dfe

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/commander/java/com/mcmoddev/mmdbot/commander/commands/HelpCommand.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.mcmoddev.mmdbot.commander.annotation.RegisterSlashCommand;
2828
import com.mcmoddev.mmdbot.core.commands.component.Component;
2929
import com.mcmoddev.mmdbot.core.commands.paginate.PaginatedCommand;
30+
import com.mcmoddev.mmdbot.core.commands.paginate.Paginator;
3031
import net.dv8tion.jda.api.EmbedBuilder;
3132
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
3233
import net.dv8tion.jda.api.interactions.commands.OptionType;
@@ -57,7 +58,12 @@ public class HelpCommand extends PaginatedCommand {
5758
public static final String ISSUE_TRACKER = "https://github.com/MinecraftModDevelopment/MMDBot/issues";
5859

5960
private HelpCommand() {
60-
super(TheCommander.getComponentListener("help-cmd"), Component.Lifespan.TEMPORARY, 25);
61+
super(
62+
Paginator.builder(TheCommander.getComponentListener("help-cmd"))
63+
.buttonOrder(Paginator.NATURAL_BUTTON_ORDER)
64+
.lifespan(Component.Lifespan.TEMPORARY)
65+
.itemsPerPage(25)
66+
);
6167
name = "help";
6268
help = "Show all commands, or detailed information about a particular command.";
6369
guildOnly = false;

src/commander/java/com/mcmoddev/mmdbot/commander/commands/XkcdCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import java.util.Random;
4444

4545
@Slf4j
46-
public class XkcdCommand extends PaginatedCommand {
46+
public final class XkcdCommand extends PaginatedCommand {
4747

4848
public static final URL LATEST_COMIC = Utils.rethrowSupplier(() -> new URL("https://xkcd.com/info.0.json")).get();
4949
public static final Random RANDOM = new Random();
@@ -73,7 +73,8 @@ protected EmbedBuilder getEmbed(final int startingIndex, final int maximum, fina
7373
return new EmbedBuilder()
7474
.setTitle(xkcd.safe_title())
7575
.setDescription(xkcd.alt())
76-
.setImage(xkcd.img());
76+
.setImage(xkcd.img())
77+
.addField("Date", xkcd.day() + "/" + xkcd.month() + "/" + xkcd.year(), true);
7778
} catch (IOException e) {
7879
log.warn("Exception trying to resolve comic ", e);
7980
return new EmbedBuilder()

src/core/java/com/mcmoddev/mmdbot/core/commands/paginate/Paginator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
public interface Paginator {
4545
ButtonFactory DEFAULT_BUTTON_FACTORY = ButtonFactory.emoji(ButtonStyle.PRIMARY, fromMarkdown("◀️"), fromMarkdown("▶️"), fromMarkdown("⏮️"), fromMarkdown("⏭️"));
4646
List<ButtonType> DEFAULT_BUTTON_ORDER = List.of(ButtonType.PREVIOUS, ButtonType.DISMISS, ButtonType.NEXT);
47+
List<ButtonType> NATURAL_BUTTON_ORDER = List.of(ButtonType.FIRST, ButtonType.PREVIOUS, ButtonType.DISMISS, ButtonType.NEXT, ButtonType.LAST);
4748

4849
/**
4950
* Gets the component listener for handling the pagination. <br>

0 commit comments

Comments
 (0)