Skip to content

Commit b16359e

Browse files
Merged #191 into current
1 parent b3f02e9 commit b16359e

4 files changed

Lines changed: 28 additions & 28 deletions

File tree

‎src/main/java/net/javadiscord/javabot/events/InteractionListener.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import lombok.extern.slf4j.Slf4j;
44
import net.dv8tion.jda.api.entities.Role;
55
import net.dv8tion.jda.api.entities.ThreadChannel;
6-
import net.dv8tion.jda.api.events.interaction.ButtonClickEvent;
7-
import net.dv8tion.jda.api.events.interaction.SelectionMenuEvent;
6+
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
7+
import net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent;
88
import net.dv8tion.jda.api.hooks.ListenerAdapter;
99
import net.javadiscord.javabot.Bot;
1010
import net.javadiscord.javabot.command.Responses;
@@ -24,7 +24,7 @@ public class InteractionListener extends ListenerAdapter {
2424
// TODO: add Context-Menu Commands (once they're available in JDA)
2525

2626
@Override
27-
public void onSelectionMenu(SelectionMenuEvent event) {
27+
public void onSelectMenuInteraction(SelectMenuInteractionEvent event) {
2828
if (event.getUser().isBot()) return;
2929
event.deferEdit().queue();
3030
String[] id = event.getComponentId().split(":");
@@ -45,7 +45,7 @@ public void onSelectionMenu(SelectionMenuEvent event) {
4545
}
4646

4747
@Override
48-
public void onButtonClick(ButtonClickEvent event) {
48+
public void onButtonInteraction(ButtonInteractionEvent event) {
4949
if (event.getUser().isBot()) return;
5050
event.deferEdit().queue();
5151
String[] id = event.getComponentId().split(":");
@@ -79,9 +79,9 @@ public void onButtonClick(ButtonClickEvent event) {
7979
* + May be useful for Context Menu Interactions.
8080
*
8181
* @param id The button's id, split by ":".
82-
* @param event The {@link ButtonClickEvent} that is fired upon use.
82+
* @param event The {@link ButtonInteractionEvent} that is fired upon use.
8383
*/
84-
private void handleUtils(String[] id, ButtonClickEvent event) {
84+
private void handleUtils(String[] id, ButtonInteractionEvent event) {
8585
var service = new ModerationService(event.getInteraction());
8686
switch (id[1]) {
8787
case "delete" -> event.getHook().deleteOriginal().queue();
@@ -105,7 +105,7 @@ private void handleUtils(String[] id, ButtonClickEvent event) {
105105
}
106106
}
107107

108-
private void handleReactionRoles(String[] id, ButtonClickEvent event) {
108+
private void handleReactionRoles(String[] id, ButtonInteractionEvent event) {
109109
String roleID = id[1];
110110
boolean permanent = Boolean.parseBoolean(id[2]);
111111

‎src/main/java/net/javadiscord/javabot/systems/qotw/QOTWCloseSubmissionsJob.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import net.dv8tion.jda.api.entities.Message;
66
import net.dv8tion.jda.api.entities.MessageChannel;
77
import net.dv8tion.jda.api.interactions.components.ActionRow;
8-
import net.dv8tion.jda.api.interactions.components.Button;
8+
import net.dv8tion.jda.api.interactions.components.buttons.Button;
99
import net.javadiscord.javabot.Bot;
1010
import net.javadiscord.javabot.data.config.guild.QOTWConfig;
1111
import net.javadiscord.javabot.systems.qotw.submissions.SubmissionControlsManager;

‎src/main/java/net/javadiscord/javabot/systems/qotw/submissions/SubmissionControlsManager.java‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import lombok.extern.slf4j.Slf4j;
55
import net.dv8tion.jda.api.EmbedBuilder;
66
import net.dv8tion.jda.api.entities.*;
7-
import net.dv8tion.jda.api.events.interaction.ButtonClickEvent;
8-
import net.dv8tion.jda.api.events.interaction.SelectionMenuEvent;
7+
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
8+
import net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent;
99
import net.dv8tion.jda.api.interactions.components.ActionRow;
10-
import net.dv8tion.jda.api.interactions.components.Button;
11-
import net.dv8tion.jda.api.interactions.components.selections.SelectionMenu;
10+
import net.dv8tion.jda.api.interactions.components.buttons.Button;
11+
import net.dv8tion.jda.api.interactions.components.selections.SelectMenu;
1212
import net.javadiscord.javabot.Bot;
1313
import net.javadiscord.javabot.command.Responses;
1414
import net.javadiscord.javabot.data.config.guild.QOTWConfig;
@@ -68,9 +68,9 @@ private boolean hasPermissions(Member member) {
6868
* Handles Button interactions regarding the Submission Controls System.
6969
*
7070
* @param id The button's id, split by ":".
71-
* @param event The {@link ButtonClickEvent} that is fired upon use.
71+
* @param event The {@link ButtonInteractionEvent} that is fired upon use.
7272
*/
73-
public void handleButtons(String[] id, ButtonClickEvent event) {
73+
public void handleButtons(String[] id, ButtonInteractionEvent event) {
7474
if (!hasPermissions(event.getMember())) {
7575
event.getHook().sendMessage("Insufficient Permissions.").setEphemeral(true).queue();
7676
return;
@@ -92,9 +92,9 @@ public void handleButtons(String[] id, ButtonClickEvent event) {
9292
* Handles Select Menu interactions regarding the Submission Controls System.
9393
*
9494
* @param id The SelectionMenu's id.
95-
* @param event The {@link SelectionMenuEvent} that is fired upon use.
95+
* @param event The {@link SelectMenuInteractionEvent} that is fired upon use.
9696
*/
97-
public void handleSelectMenus(String[] id, SelectionMenuEvent event) {
97+
public void handleSelectMenus(String[] id, SelectMenuInteractionEvent event) {
9898
if (!hasPermissions(event.getMember())) {
9999
event.getHook().sendMessage("Insufficient Permissions.").setEphemeral(true).queue();
100100
return;
@@ -110,7 +110,7 @@ public void handleSelectMenus(String[] id, SelectionMenuEvent event) {
110110
}
111111
}
112112

113-
private void acceptSubmission(ButtonClickEvent event, ThreadChannel thread) {
113+
private void acceptSubmission(ButtonInteractionEvent event, ThreadChannel thread) {
114114
try (var con = Bot.dataSource.getConnection()) {
115115
var repo = new QOTWSubmissionRepository(con);
116116
var submissionOptional = repo.getSubmissionByThreadId(thread.getIdLong());
@@ -137,11 +137,11 @@ private void acceptSubmission(ButtonClickEvent event, ThreadChannel thread) {
137137
}
138138
}
139139

140-
private void declineButtonSubmission(ButtonClickEvent event) {
140+
private void declineButtonSubmission(ButtonInteractionEvent event) {
141141
event.getMessage().editMessageComponents(ActionRow.of(this.buildDeclineMenu())).queue();
142142
}
143143

144-
private void declineSelectSubmission(SelectionMenuEvent event, ThreadChannel thread) {
144+
private void declineSelectSubmission(SelectMenuInteractionEvent event, ThreadChannel thread) {
145145
var reasons = String.join(", ", event.getValues());
146146
try (var con = Bot.dataSource.getConnection()) {
147147
var repo = new QOTWSubmissionRepository(con);
@@ -173,7 +173,7 @@ private void declineSelectSubmission(SelectionMenuEvent event, ThreadChannel thr
173173
}
174174
}
175175

176-
private void deleteSubmission(ButtonClickEvent event, ThreadChannel thread) {
176+
private void deleteSubmission(ButtonInteractionEvent event, ThreadChannel thread) {
177177
thread.delete().queueAfter(10, TimeUnit.SECONDS);
178178
log.info("{} deleted submission thread {}", event.getUser().getAsTag(), thread.getName());
179179
GuildUtils.getLogChannel(event.getGuild()).sendMessageFormat("%s deleted submission thread `%s`", event.getUser().getAsTag(), thread.getName()).queue();
@@ -208,8 +208,8 @@ private List<ActionRow> buildInteractionControls() {
208208
Button.secondary("submission-controls:delete", "🗑️")));
209209
}
210210

211-
private SelectionMenu buildDeclineMenu() {
212-
return SelectionMenu.create("submission-controls-select:decline")
211+
private SelectMenu buildDeclineMenu() {
212+
return SelectMenu.create("submission-controls-select:decline")
213213
.setPlaceholder("Select a reason for declining this submission.")
214214
.setRequiredRange(1, 3)
215215
.addOption("Wrong Answer", "Wrong Answer", "The content of the submission was not correct.")

‎src/main/java/net/javadiscord/javabot/systems/qotw/submissions/SubmissionManager.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import net.dv8tion.jda.api.entities.MessageEmbed;
88
import net.dv8tion.jda.api.entities.ThreadChannel;
99
import net.dv8tion.jda.api.entities.User;
10-
import net.dv8tion.jda.api.events.interaction.ButtonClickEvent;
10+
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
1111
import net.dv8tion.jda.api.interactions.components.ActionRow;
12-
import net.dv8tion.jda.api.interactions.components.Button;
12+
import net.dv8tion.jda.api.interactions.components.buttons.Button;
1313
import net.dv8tion.jda.api.requests.restaction.WebhookMessageAction;
1414
import net.javadiscord.javabot.Bot;
1515
import net.javadiscord.javabot.command.Responses;
@@ -35,11 +35,11 @@ public class SubmissionManager {
3535
/**
3636
* Handles the "Submit your Answer" Button interaction.
3737
*
38-
* @param event The {@link ButtonClickEvent} that is fired upon use.
38+
* @param event The {@link ButtonInteractionEvent} that is fired upon use.
3939
* @param questionNumber The current qotw-week number.
4040
* @return A {@link WebhookMessageAction}.
4141
*/
42-
public WebhookMessageAction<?> handleSubmission(ButtonClickEvent event, int questionNumber) {
42+
public WebhookMessageAction<?> handleSubmission(ButtonInteractionEvent event, int questionNumber) {
4343
var member = event.getMember();
4444
if (!canCreateSubmissions(member)) {
4545
return Responses.warning(event.getHook(), "You're not eligible to create a new submission thread.");
@@ -75,9 +75,9 @@ public WebhookMessageAction<?> handleSubmission(ButtonClickEvent event, int ques
7575
/**
7676
* Handles the "Delete Submission" Button.
7777
*
78-
* @param event The {@link ButtonClickEvent} that is fired upon use.
78+
* @param event The {@link ButtonInteractionEvent} that is fired upon use.
7979
*/
80-
public void handleThreadDeletion(ButtonClickEvent event) {
80+
public void handleThreadDeletion(ButtonInteractionEvent event) {
8181
var thread = (ThreadChannel) event.getGuildChannel();
8282
try (var con = Bot.dataSource.getConnection()) {
8383
var repo = new QOTWSubmissionRepository(con);

0 commit comments

Comments
 (0)