Skip to content

Commit 2c5865d

Browse files
committed
feat(deps): upgrade to jda v6
1 parent fd72e36 commit 2c5865d

File tree

11 files changed

+206
-91
lines changed

11 files changed

+206
-91
lines changed

build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ repositories {
3939
}
4040

4141
dependencies {
42-
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.5.18'
43-
implementation(group: 'net.dv8tion', name: 'JDA', version:'5.6.1'){
42+
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.5.23'
43+
implementation(group: 'net.dv8tion', name: 'JDA', version:'6.2.0'){
4444
exclude(module: 'opus-java')
4545
}
46-
implementation group: 'pw.chew', name: 'jda-chewtils-commons', version: '2.1'
47-
implementation group: 'pw.chew', name: 'jda-chewtils-command', version: '2.1'
46+
implementation group: 'pw.chew', name: 'jda-chewtils-commons', version: '2.2.1'
47+
implementation group: 'pw.chew', name: 'jda-chewtils-command', version: '2.2.1'
4848
implementation group: 'org.spongepowered', name: 'configurate-gson', version: '4.2.0'
4949

5050
implementation group: 'io.codemc.api', name: 'codemc-api', version: '1.2.2'
5151
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '1.10.2'
5252
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-serialization-json', version: '1.9.0'
53-
implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '3.5.5'
53+
implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '3.5.7'
5454
implementation group: 'org.jetbrains.exposed', name: 'exposed-core', version: '0.61.0'
5555
implementation group: 'org.jetbrains.exposed', name: 'exposed-jdbc', version: '0.61.0'
5656

57-
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.13.4'
58-
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher'
59-
testImplementation group: 'dev.coly', name: 'JDATesting', version: '0.7.0'
57+
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '6.0.1'
58+
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '6.0.1'
6059
testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.18.0'
60+
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '6.0.1'
6161
}
6262

6363
tasks {

src/main/java/io/codemc/bot/CodeMCBot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ final void initializeAPI() {
168168
logger.info("GitHub API Token set");
169169
}
170170

171-
private void login(CommandClientBuilder clientBuilder, String token) throws LoginException{
171+
private void login(CommandClientBuilder clientBuilder, String token) {
172172
logger.info("Adding commands...");
173173
clientBuilder.addSlashCommands(
174174
new CmdApplication(this),

src/main/java/io/codemc/bot/commands/CmdCodeMC.java

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,13 @@ MessageEmbed createInfoEmbed(String user) {
195195
String format = ((JsonPrimitive) info.get("format")).getContent();
196196
String type = ((JsonPrimitive) info.get("type")).getContent();
197197

198-
MessageEmbed embed = CommandUtil.getEmbed()
198+
return CommandUtil.getEmbed()
199199
.setTitle(user, nexusUrl + "/#browse/browse:" + repository)
200200
.setDescription("Information about the Nexus Repository.")
201201
.addField("Format", format, true)
202202
.addField("Type", type, true)
203203
.setTimestamp(Instant.now())
204204
.build();
205-
206-
return embed;
207205
}
208206
}
209207

@@ -231,15 +229,7 @@ public void withModalReply(SlashCommandEvent event) {
231229
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
232230
String username = event.getOption("username", null, OptionMapping::getAsString);
233231

234-
if (username == null || username.isEmpty()) {
235-
CommandUtil.EmbedReply.from(hook).error("Invalid Jenkins User provided!").send();
236-
return;
237-
}
238-
239-
if (!JenkinsAPI.existsUser(username)) {
240-
CommandUtil.EmbedReply.from(hook).error("The user does not have a Jenkins account!").send();
241-
return;
242-
}
232+
if (checkUsername(hook, username)) return;
243233

244234
User dbUser = DatabaseAPI.getUser(username);
245235

@@ -288,6 +278,20 @@ public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild g
288278
)
289279
);
290280
}
281+
282+
private static boolean checkUsername(InteractionHook hook, String username) {
283+
if (username == null || username.isEmpty()) {
284+
CommandUtil.EmbedReply.from(hook).error("Invalid Jenkins User provided!").send();
285+
return true;
286+
}
287+
288+
if (!JenkinsAPI.existsUser(username)) {
289+
CommandUtil.EmbedReply.from(hook).error("The user does not have a Jenkins account!").send();
290+
return true;
291+
}
292+
293+
return false;
294+
}
291295
}
292296

293297
@VisibleForTesting
@@ -390,15 +394,7 @@ public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild g
390394
String username = event.getOption("username", null, OptionMapping::getAsString);
391395
Member target = event.getOption("discord", null, OptionMapping::getAsMember);
392396

393-
if (username == null || username.isEmpty()) {
394-
CommandUtil.EmbedReply.from(hook).error("Invalid Jenkins User provided!").send();
395-
return;
396-
}
397-
398-
if (!JenkinsAPI.existsUser(username)) {
399-
CommandUtil.EmbedReply.from(hook).error("The user does not have a Jenkins account!").send();
400-
return;
401-
}
397+
if (Remove.checkUsername(hook, username)) return;
402398

403399
if (target == null) {
404400
CommandUtil.EmbedReply.from(hook).error("Invalid Discord User provided!").send();

src/main/java/io/codemc/bot/commands/CmdMsg.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
import com.jagrosh.jdautilities.command.SlashCommandEvent;
2323
import io.codemc.bot.CodeMCBot;
2424
import io.codemc.bot.utils.CommandUtil;
25+
import net.dv8tion.jda.api.components.label.Label;
26+
import net.dv8tion.jda.api.components.textinput.TextInput;
27+
import net.dv8tion.jda.api.components.textinput.TextInputStyle;
2528
import net.dv8tion.jda.api.entities.Guild;
2629
import net.dv8tion.jda.api.entities.Member;
2730
import net.dv8tion.jda.api.entities.Message;
@@ -31,10 +34,7 @@
3134
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
3235
import net.dv8tion.jda.api.interactions.commands.OptionType;
3336
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
34-
import net.dv8tion.jda.api.interactions.components.ActionRow;
35-
import net.dv8tion.jda.api.interactions.components.text.TextInput;
36-
import net.dv8tion.jda.api.interactions.components.text.TextInputStyle;
37-
import net.dv8tion.jda.api.interactions.modals.Modal;
37+
import net.dv8tion.jda.api.modals.Modal;
3838

3939
import java.util.Arrays;
4040

@@ -97,13 +97,15 @@ public void withModalReply(SlashCommandEvent event){
9797
return;
9898
}
9999

100-
TextInput input = TextInput.create("message", "Message", TextInputStyle.PARAGRAPH)
100+
TextInput input = TextInput.create("message", TextInputStyle.PARAGRAPH)
101101
.setMaxLength(asEmbed ? TextInput.MAX_VALUE_LENGTH : Message.MAX_CONTENT_LENGTH)
102102
.setRequired(true)
103103
.build();
104+
105+
Label label = Label.of("Message", input);
104106

105107
Modal modal = Modal.create("message:post:" + channel.getId() + ":" + asEmbed, "Send Message")
106-
.addComponents(ActionRow.of(input))
108+
.addComponents(label)
107109
.build();
108110

109111
event.replyModal(modal).queue();
@@ -152,13 +154,15 @@ public void withModalReply(SlashCommandEvent event){
152154
return;
153155
}
154156

155-
TextInput input = TextInput.create("message", "Message", TextInputStyle.PARAGRAPH)
157+
TextInput input = TextInput.create("message", TextInputStyle.PARAGRAPH)
156158
.setMaxLength(asEmbed ? 4000 : Message.MAX_CONTENT_LENGTH)
157159
.setRequired(true)
158160
.build();
161+
162+
Label label = Label.of("Message", input);
159163

160164
Modal modal = Modal.create("message:edit:" + channel.getId() + ":" + asEmbed + ":" + messageId, "Send Message")
161-
.addComponents(ActionRow.of(input))
165+
.addComponents(label)
162166
.build();
163167

164168
event.replyModal(modal).queue();

src/main/java/io/codemc/bot/commands/CmdSubmit.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
import com.jagrosh.jdautilities.command.SlashCommandEvent;
2222
import io.codemc.bot.CodeMCBot;
23+
import net.dv8tion.jda.api.components.label.Label;
24+
import net.dv8tion.jda.api.components.textinput.TextInput;
25+
import net.dv8tion.jda.api.components.textinput.TextInputStyle;
2326
import net.dv8tion.jda.api.entities.Guild;
2427
import net.dv8tion.jda.api.entities.Member;
2528
import net.dv8tion.jda.api.entities.MessageEmbed;
2629
import net.dv8tion.jda.api.interactions.InteractionHook;
27-
import net.dv8tion.jda.api.interactions.components.ActionRow;
28-
import net.dv8tion.jda.api.interactions.components.text.TextInput;
29-
import net.dv8tion.jda.api.interactions.components.text.TextInputStyle;
30-
import net.dv8tion.jda.api.interactions.modals.Modal;
30+
import net.dv8tion.jda.api.modals.Modal;
3131

3232
public class CmdSubmit extends BotCommand{
3333

@@ -45,31 +45,33 @@ public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild g
4545

4646
@Override
4747
public void withModalReply(SlashCommandEvent event){
48-
TextInput user = TextInput.create("user", "GitHub Username", TextInputStyle.SHORT)
48+
TextInput user = TextInput.create("user", TextInputStyle.SHORT)
4949
.setPlaceholder("CodeMC")
5050
.setRequired(true)
5151
.build();
52-
TextInput repo = TextInput.create("repo", "Repository Name", TextInputStyle.SHORT)
52+
Label userLabel = Label.of("GitHub Username", user);
53+
54+
TextInput repo = TextInput.create("repo", TextInputStyle.SHORT)
5355
.setPlaceholder("Bot")
5456
.setRequired(true)
5557
.build();
56-
TextInput repoLink = TextInput.create("repoLink", "Repository Link (Leave blank if on GitHub)", TextInputStyle.SHORT)
58+
Label repoLabel = Label.of("Repository Name", repo);
59+
60+
TextInput repoLink = TextInput.create("repoLink", TextInputStyle.SHORT)
5761
.setPlaceholder("https://git.example.com/CodeMC/Bot")
5862
.setRequired(false)
5963
.build();
60-
TextInput description = TextInput.create("description", "Description", TextInputStyle.PARAGRAPH)
64+
Label repoLinkLabel = Label.of("Repository Link (Leave blank if on GitHub)", repoLink);
65+
66+
TextInput description = TextInput.create("description", TextInputStyle.PARAGRAPH)
6167
.setPlaceholder("Discord Bot for the CodeMC Server.")
6268
.setRequired(true)
6369
.setMaxLength(MessageEmbed.VALUE_MAX_LENGTH)
6470
.build();
71+
Label descriptionLabel = Label.of("Project Description", description);
6572

6673
Modal modal = Modal.create("submit", "Join Request")
67-
.addComponents(
68-
ActionRow.of(user),
69-
ActionRow.of(repo),
70-
ActionRow.of(repoLink),
71-
ActionRow.of(description)
72-
)
74+
.addComponents(userLabel, repoLabel, repoLinkLabel, descriptionLabel)
7375
.build();
7476

7577
event.replyModal(modal).queue();

src/main/java/io/codemc/bot/listeners/ButtonListener.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
import io.codemc.bot.CodeMCBot;
2222
import io.codemc.bot.utils.ApplicationHandler;
2323
import io.codemc.bot.utils.CommandUtil;
24+
import net.dv8tion.jda.api.components.label.Label;
25+
import net.dv8tion.jda.api.components.textinput.TextInput;
26+
import net.dv8tion.jda.api.components.textinput.TextInputStyle;
2427
import net.dv8tion.jda.api.entities.Guild;
2528
import net.dv8tion.jda.api.entities.Member;
2629
import net.dv8tion.jda.api.entities.MessageEmbed;
2730
import net.dv8tion.jda.api.entities.Role;
2831
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
2932
import net.dv8tion.jda.api.hooks.ListenerAdapter;
30-
import net.dv8tion.jda.api.interactions.components.ActionRow;
31-
import net.dv8tion.jda.api.interactions.components.text.TextInput;
32-
import net.dv8tion.jda.api.interactions.components.text.TextInputStyle;
33-
import net.dv8tion.jda.api.interactions.modals.Modal;
33+
import net.dv8tion.jda.api.modals.Modal;
3434
import org.jetbrains.annotations.NotNull;
3535
import org.jetbrains.annotations.VisibleForTesting;
3636
import org.slf4j.Logger;
@@ -55,7 +55,7 @@ public void onButtonInteraction(@NotNull ButtonInteractionEvent event){
5555
return;
5656
}
5757

58-
String id = event.getButton().getId();
58+
String id = event.getButton().getCustomId();
5959
if (id == null) {
6060
CommandUtil.EmbedReply.from(event).error("Received Button Interaction with no ID!").send();
6161
logger.error("Received Button Interaction with no ID!");
@@ -109,15 +109,17 @@ public void onButtonInteraction(@NotNull ButtonInteractionEvent event){
109109
CommandUtil.EmbedReply.from(event).error("You lack permissions to perform this action.").send();
110110
return;
111111
}
112-
113-
TextInput reason = TextInput.create("reason", "Reason", TextInputStyle.PARAGRAPH)
114-
.setPlaceholder("(Leave empty for no reason)")
112+
113+
TextInput input = TextInput.create("reason", TextInputStyle.PARAGRAPH)
114+
.setPlaceholder("The reason for denying this application. Leave blank for no reason.")
115115
.setMaxLength(MessageEmbed.VALUE_MAX_LENGTH)
116116
.setRequired(false)
117117
.build();
118+
119+
Label reason = Label.of("Reason", input);
118120

119121
Modal modal = Modal.create("deny_application:" + event.getMessageId(), "Deny Application")
120-
.addComponents(ActionRow.of(reason))
122+
.addComponents(reason)
121123
.build();
122124

123125
event.replyModal(modal).queue();

src/main/java/io/codemc/bot/listeners/ModalListener.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import io.codemc.bot.CodeMCBot;
2424
import io.codemc.bot.utils.ApplicationHandler;
2525
import io.codemc.bot.utils.CommandUtil;
26+
import net.dv8tion.jda.api.components.actionrow.ActionRow;
27+
import net.dv8tion.jda.api.components.buttons.Button;
2628
import net.dv8tion.jda.api.entities.Guild;
2729
import net.dv8tion.jda.api.entities.Message;
2830
import net.dv8tion.jda.api.entities.MessageEmbed;
@@ -31,7 +33,6 @@
3133
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
3234
import net.dv8tion.jda.api.hooks.ListenerAdapter;
3335
import net.dv8tion.jda.api.interactions.InteractionHook;
34-
import net.dv8tion.jda.api.interactions.components.buttons.Button;
3536
import net.dv8tion.jda.api.interactions.modals.ModalMapping;
3637
import net.dv8tion.jda.api.utils.MarkdownUtil;
3738
import org.jetbrains.annotations.NotNull;
@@ -104,9 +105,11 @@ public void onModalInteraction(@NotNull ModalInteractionEvent event){
104105
MessageEmbed embed = CommandUtil.requestEmbed(userLink, repoLink, submitter, description);
105106

106107
requestChannel.sendMessageEmbeds(embed)
107-
.setActionRow(
108-
Button.success("application:accept:" + user + ":" + repo, "Accept"),
109-
Button.danger("application:deny:" + user + ":" + repo, "Deny")
108+
.setComponents(
109+
ActionRow.of(
110+
Button.success("application:accept:" + user + ":" + repo, "Accept"),
111+
Button.danger("application:deny:" + user + ":" + repo, "Deny")
112+
)
110113
).queue(
111114
message -> {
112115
CommandUtil.EmbedReply.from(hook).success(

0 commit comments

Comments
 (0)