Skip to content

Commit cd496a8

Browse files
Upgraded to JDA 5.0.0-alpha.10 (Still Xirado's fork for modal support)
1 parent 636cb70 commit cd496a8

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies {
2020
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
2121
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
2222

23-
implementation 'com.github.Xirado:JDA:6adee1ec24'
23+
implementation 'com.github.Xirado:JDA:7e0ffc5c83'
2424
implementation 'com.google.code.gson:gson:2.9.0'
2525
implementation 'org.yaml:snakeyaml:1.29'
2626
implementation 'com.google.re2j:re2j:1.6'
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package net.javadiscord.javabot.command.interfaces;
22

33
import net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent;
4-
import net.dv8tion.jda.api.interactions.InteractionHook;
54
import net.dv8tion.jda.api.requests.restaction.interactions.InteractionCallbackAction;
65
import net.javadiscord.javabot.command.ResponseException;
76

87
/**
98
* Interface that handles Discord's Message Context Commands.
109
*/
1110
public interface MessageContextCommand {
12-
InteractionCallbackAction<InteractionHook> handleMessageContextCommandInteraction(MessageContextInteractionEvent event) throws ResponseException;
11+
InteractionCallbackAction<?> handleMessageContextCommandInteraction(MessageContextInteractionEvent event) throws ResponseException;
1312
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package net.javadiscord.javabot.command.interfaces;
22

33
import net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent;
4-
import net.dv8tion.jda.api.interactions.InteractionHook;
54
import net.dv8tion.jda.api.requests.restaction.interactions.InteractionCallbackAction;
65
import net.javadiscord.javabot.command.ResponseException;
76

87
/**
98
* Interface that handles Discord's User Context Commands.
109
*/
1110
public interface UserContextCommand {
12-
InteractionCallbackAction<InteractionHook> handleUserContextCommandInteraction(UserContextInteractionEvent event) throws ResponseException;
11+
InteractionCallbackAction<?> handleUserContextCommandInteraction(UserContextInteractionEvent event) throws ResponseException;
1312
}

src/main/java/net/javadiscord/javabot/systems/commands/FormatCodeCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
77
import net.dv8tion.jda.api.interactions.components.ActionRow;
88
import net.dv8tion.jda.api.interactions.components.buttons.Button;
9+
import net.dv8tion.jda.api.requests.restaction.interactions.InteractionCallbackAction;
910
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
1011
import net.javadiscord.javabot.command.Responses;
1112
import net.javadiscord.javabot.command.interfaces.MessageContextCommand;
@@ -55,7 +56,7 @@ public ReplyCallbackAction handleSlashCommandInteraction(SlashCommandInteraction
5556
}
5657

5758
@Override
58-
public ReplyCallbackAction handleMessageContextCommandInteraction(MessageContextInteractionEvent event) {
59+
public InteractionCallbackAction<?> handleMessageContextCommandInteraction(MessageContextInteractionEvent event) {
5960
return event.replyFormat("```java\n%s\n```", StringUtils.standardSanitizer().compute(event.getTarget().getContentRaw()))
6061
.allowedMentions(List.of())
6162
.addActionRows(this.buildActionRow(event.getTarget()));

src/main/java/net/javadiscord/javabot/systems/moderation/ReportCommand.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import net.dv8tion.jda.api.requests.restaction.interactions.InteractionCallbackAction;
1919
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
2020
import net.javadiscord.javabot.Bot;
21-
import net.javadiscord.javabot.command.ResponseException;
2221
import net.javadiscord.javabot.command.Responses;
2322
import net.javadiscord.javabot.command.interfaces.MessageContextCommand;
2423
import net.javadiscord.javabot.command.interfaces.UserContextCommand;
@@ -50,7 +49,7 @@ private Modal buildUserReportModal(UserContextInteractionEvent event) {
5049
.setMaxLength(MessageEmbed.VALUE_MAX_LENGTH)
5150
.build();
5251
String title = "Report " + event.getTarget().getAsTag();
53-
return Modal.create("report:user:" + event.getTarget().getId(), title.substring(0, Math.min(title.length(), Modal.TITLE_MAX_LENGTH)))
52+
return Modal.create("report:user:" + event.getTarget().getId(), title.substring(0, Math.min(title.length(), Modal.MAX_TITLE_LENGTH)))
5453
.addActionRows(ActionRow.of(messageInput))
5554
.build();
5655
}
@@ -71,7 +70,7 @@ private Modal buildMessageReportModal(MessageContextInteractionEvent event) {
7170
TextInput messageInput = TextInput.create(REASON_OPTION_NAME, "Report Description", TextInputStyle.PARAGRAPH)
7271
.setMaxLength(MessageEmbed.VALUE_MAX_LENGTH)
7372
.build();
74-
return Modal.create("report:message:" + event.getTarget().getId(), title.substring(0, Math.min(title.length(), Modal.TITLE_MAX_LENGTH)))
73+
return Modal.create("report:message:" + event.getTarget().getId(), title.substring(0, Math.min(title.length(), Modal.MAX_TITLE_LENGTH)))
7574
.addActionRows(ActionRow.of(messageInput))
7675
.build();
7776
}
@@ -188,23 +187,23 @@ private EmbedBuilder buildReportEmbed(User reported, String reason, User reporte
188187
}
189188

190189
@Override
191-
public InteractionCallbackAction<InteractionHook> handleMessageContextCommandInteraction(MessageContextInteractionEvent event) throws ResponseException {
190+
public InteractionCallbackAction<?> handleMessageContextCommandInteraction(MessageContextInteractionEvent event) {
192191
if (event.getTarget().getAuthor().equals(event.getUser())) {
193192
return Responses.error(event, "You cannot perform this action on yourself.");
194193
}
195194
return event.replyModal(this.buildMessageReportModal(event));
196195
}
197196

198197
@Override
199-
public InteractionCallbackAction<InteractionHook> handleUserContextCommandInteraction(UserContextInteractionEvent event) throws ResponseException {
198+
public InteractionCallbackAction<?> handleUserContextCommandInteraction(UserContextInteractionEvent event) {
200199
if (event.getTarget().equals(event.getUser())) {
201200
return Responses.error(event, "You cannot perform this action on yourself.");
202201
}
203202
return event.replyModal(this.buildUserReportModal(event));
204203
}
205204

206205
@Override
207-
protected ReplyCallbackAction handleModerationActionCommand(SlashCommandInteractionEvent event, Member commandUser, Member target) throws ResponseException {
206+
protected ReplyCallbackAction handleModerationActionCommand(SlashCommandInteractionEvent event, Member commandUser, Member target) {
208207
this.handleUserReport(event.getHook(), event.getOption("reason", "N/A", OptionMapping::getAsString), commandUser.getUser(), target.getId());
209208
return event.deferReply(true);
210209
}

src/main/java/net/javadiscord/javabot/systems/moderation/warn/WarnsCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
77
import net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent;
88
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
9+
import net.dv8tion.jda.api.requests.restaction.interactions.InteractionCallbackAction;
910
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
1011
import net.javadiscord.javabot.Bot;
1112
import net.javadiscord.javabot.command.ResponseException;
@@ -39,7 +40,7 @@ public ReplyCallbackAction handleSlashCommandInteraction(SlashCommandInteraction
3940
}
4041

4142
@Override
42-
public ReplyCallbackAction handleUserContextCommandInteraction(UserContextInteractionEvent event) throws ResponseException {
43+
public InteractionCallbackAction<?> handleUserContextCommandInteraction(UserContextInteractionEvent event) throws ResponseException {
4344
LocalDateTime cutoff = LocalDateTime.now().minusDays(Bot.config.get(event.getGuild()).getModeration().getWarnTimeoutDays());
4445
Member member = event.getTargetMember();
4546
try (var con = Bot.dataSource.getConnection()) {

0 commit comments

Comments
 (0)