Skip to content

Commit

Permalink
Merge pull request #77
Browse files Browse the repository at this point in the history
Update patch{#66} branch
  • Loading branch information
pitzzahh authored Feb 27, 2023
2 parents 59c7029 + d1ea388 commit a916bd6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<version>3.0.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.17</version>
<version>5.0.0-beta.4</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -119,12 +135,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())
Expand Down

0 comments on commit a916bd6

Please sign in to comment.