Skip to content

Commit 2402c73

Browse files
committed
Using proper button factories (CR Tais)
1 parent d92fcaa commit 2402c73

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

application/src/main/java/org/togetherjava/tjbot/commands/mathcommands/TeXCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
55
import net.dv8tion.jda.api.interactions.commands.OptionType;
66
import net.dv8tion.jda.api.interactions.components.Button;
7-
import net.dv8tion.jda.api.interactions.components.ButtonStyle;
87
import org.jetbrains.annotations.NotNull;
98
import org.scilab.forge.jlatexmath.ParseException;
109
import org.scilab.forge.jlatexmath.TeXConstants;
@@ -15,7 +14,8 @@
1514
import org.togetherjava.tjbot.commands.SlashCommandVisibility;
1615

1716
import javax.imageio.ImageIO;
18-
import java.awt.*;
17+
import java.awt.Color;
18+
import java.awt.Image;
1919
import java.awt.image.BufferedImage;
2020
import java.io.ByteArrayOutputStream;
2121
import java.io.IOException;
@@ -88,7 +88,7 @@ public void onSlashCommand(@NotNull final SlashCommandEvent event) {
8888
}
8989
event.getHook()
9090
.editOriginal(renderedTextImageStream.toByteArray(), "tex.png")
91-
.setActionRow(Button.of(ButtonStyle.DANGER, generateComponentId(userID), "Delete"))
91+
.setActionRow(Button.danger(generateComponentId(userID), "Delete"))
9292
.queue();
9393
}
9494

application/src/main/java/org/togetherjava/tjbot/commands/moderation/scam/ScamBlocker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ If you think this was a mistake (for example, your account was hacked, but you g
261261
event.getAuthor().getIdLong(),
262262
ScamHistoryStore.hashMessageContent(event.getMessage()));
263263

264-
return ActionRow.of(Button.of(ButtonStyle.SUCCESS, generateComponentId(args), "Yes"),
265-
Button.of(ButtonStyle.DANGER, generateComponentId(args), "No"));
264+
return ActionRow.of(Button.success(generateComponentId(args), "Yes"),
265+
Button.danger(generateComponentId(args), "No"));
266266
}
267267

268268
private @NotNull String generateComponentId(@NotNull ComponentIdArguments args) {

application/src/main/java/org/togetherjava/tjbot/commands/system/ReloadCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public void onSlashCommand(@NotNull SlashCommandEvent event) {
7070
event.reply(
7171
"Are you sure? You can only reload commands a few times each day, so do not overdo this.")
7272
.addActionRow(
73-
Button.of(ButtonStyle.SUCCESS, generateComponentId(member.getId()), "Yes"),
74-
Button.of(ButtonStyle.DANGER, generateComponentId(member.getId()), "No"))
73+
Button.success(generateComponentId(member.getId()), "Yes"),
74+
Button.danger(generateComponentId(member.getId()), "No"))
7575
.queue();
7676
}
7777

application/src/test/java/org/togetherjava/tjbot/jda/ButtonClickEventBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646
* {@code
4747
* // Default message with a delete button
4848
* jdaTester.createButtonClickEvent()
49-
* .setActionRows(ActionRow.of(Button.of(ButtonStyle.DANGER, "1", "Delete"))
49+
* .setActionRows(ActionRow.of(Button.danger("1", "Delete"))
5050
* .buildWithSingleButton();
5151
*
5252
* // More complex message with a user who clicked the button that is not the message author and multiple buttons
53-
* Button clickedButton = Button.of(ButtonStyle.PRIMARY, "1", "Next");
53+
* Button clickedButton = Button.primary("1", "Next");
5454
* jdaTester.createButtonClickEvent()
5555
* .setMessage(new MessageBuilder()
5656
* .setContent("See the following entry")
@@ -61,7 +61,7 @@
6161
* .build())
6262
* .setUserWhoClicked(jdaTester.createMemberSpy(5))
6363
* .setActionRows(
64-
* ActionRow.of(Button.of(ButtonStyle.PRIMARY, "1", "Previous"),
64+
* ActionRow.of(Button.primary("1", "Previous"),
6565
* clickedButton)
6666
* .build(clickedButton);
6767
* }

0 commit comments

Comments
 (0)