From f60b3a467d10f125b72f3d54a1a7c8d5133388cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Feb 2023 01:58:11 +0000 Subject: [PATCH 1/4] build(deps): bump JDA from 5.0.0-alpha.17 to 5.0.0-beta.4 Bumps [JDA](https://github.com/DV8FromTheWorld/JDA) from 5.0.0-alpha.17 to 5.0.0-beta.4. - [Release notes](https://github.com/DV8FromTheWorld/JDA/releases) - [Commits](https://github.com/DV8FromTheWorld/JDA/compare/v5.0.0-alpha.17...v5.0.0-beta.4) --- updated-dependencies: - dependency-name: net.dv8tion:JDA dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0bdf892..af55204 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ net.dv8tion JDA - 5.0.0-alpha.17 + 5.0.0-beta.4 From e9a08633bf2ce3497f739b945edf434bde4fbfef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Feb 2023 01:58:19 +0000 Subject: [PATCH 2/4] build(deps): bump spring-boot-starter-parent from 3.0.2 to 3.0.3 Bumps [spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 3.0.2 to 3.0.3. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.0.2...v3.0.3) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-parent dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0bdf892..db85abb 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 3.0.2 + 3.0.3 From 6cd9a077e247d1a07d3f8b269573b5640d242917 Mon Sep 17 00:00:00 2001 From: pitzzahh Date: Mon, 27 Feb 2023 13:41:03 +0800 Subject: [PATCH 3/4] removed: message builder #74 --- .../commands/joke/approveJoke/ApproveJoke.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/tech/araopj/springpitzzahhbot/commands/slash_command/commands/joke/approveJoke/ApproveJoke.java b/src/main/java/tech/araopj/springpitzzahhbot/commands/slash_command/commands/joke/approveJoke/ApproveJoke.java index 7f50961..2de4687 100644 --- a/src/main/java/tech/araopj/springpitzzahhbot/commands/slash_command/commands/joke/approveJoke/ApproveJoke.java +++ b/src/main/java/tech/araopj/springpitzzahhbot/commands/slash_command/commands/joke/approveJoke/ApproveJoke.java @@ -119,12 +119,6 @@ private void process(CommandContext context) { } } - messageUtilService.generateAutoDeleteMessage( - context.event(), - YELLOW, - "Testing", - String.format("Is user %s an admin? and can manage this server?: %s", context.getMember().getAsMention(), isAdmin) - ); context.getEvent() .getInteraction() .replyEmbeds(messageUtilService.getEmbedBuilder().build()) From 808c6437c62e3227729600bc227f2d5a5c30dc6f Mon Sep 17 00:00:00 2001 From: pitzzahh Date: Mon, 27 Feb 2023 13:50:05 +0800 Subject: [PATCH 4/4] add: input validation and message response #73 --- .../commands/joke/approveJoke/ApproveJoke.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/tech/araopj/springpitzzahhbot/commands/slash_command/commands/joke/approveJoke/ApproveJoke.java b/src/main/java/tech/araopj/springpitzzahhbot/commands/slash_command/commands/joke/approveJoke/ApproveJoke.java index 2de4687..8addfd8 100644 --- a/src/main/java/tech/araopj/springpitzzahhbot/commands/slash_command/commands/joke/approveJoke/ApproveJoke.java +++ b/src/main/java/tech/araopj/springpitzzahhbot/commands/slash_command/commands/joke/approveJoke/ApproveJoke.java @@ -24,6 +24,7 @@ package tech.araopj.springpitzzahhbot.commands.slash_command.commands.joke.approveJoke; +import io.github.pitzzahh.util.utilities.validation.Validator; import tech.araopj.springpitzzahhbot.commands.slash_command.commands.joke.service.JokesService; import tech.araopj.springpitzzahhbot.commands.slash_command.CommandContext; import tech.araopj.springpitzzahhbot.utilities.service.MessageUtilService; @@ -78,6 +79,21 @@ private void process(CommandContext context) { OptionMapping idOption = context.getEvent().getOption("joke-id"); if (idOption != null) { log.info("Joke id: {}", idOption.getAsString()); + boolean isNotWholeNumber = Validator.isWholeNumber().negate().test(idOption.getAsString()); + if (isNotWholeNumber) { + log.info("Joke id must be a whole number: {}", idOption.getAsString()); + messageUtilService.generateAutoDeleteMessage( + context.event(), + YELLOW, + "Testing", + String.format("Joke id must be a whole number: %s", idOption.getAsString()) + ); + context.getEvent() + .getInteraction() + .replyEmbeds(messageUtilService.getEmbedBuilder().build()) + .queue(m -> m.deleteOriginal().queueAfter(messageUtilService.getReplyDeletionDelayInMinutes(), TimeUnit.MINUTES)); + throw new IllegalArgumentException("Joke id must be a whole number"); + } boolean noJokeWithId = jokesService.getSubmittedJokes() .stream() .noneMatch(j -> j.id() == Integer.parseInt(idOption.getAsString()));