Skip to content

Commit

Permalink
Remove nonce supplyer
Browse files Browse the repository at this point in the history
  • Loading branch information
duncte123 committed Mar 11, 2024
1 parent 36b2755 commit a8d720e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugins {
}

group = "me.duncte123"
version = "${getVersionPrefix()}3.0.${getBuildNum()}"
version = "${getVersionPrefix()}3.1.${getBuildNum()}"
val archivesBaseName = "botCommons"

repositories {
Expand All @@ -36,10 +36,10 @@ java {
targetCompatibility = JavaVersion.VERSION_1_8
}

val jdaVersion = "5.0.0-beta.13"
val jdaVersion = "5.0.0-beta.21"

dependencies {
api(group = "com.fasterxml.jackson.core", name = "jackson-databind", version = "2.13.2.2")
api(group = "com.fasterxml.jackson.core", name = "jackson-databind", version = "2.16.1")
api(group = "org.jsoup", name = "jsoup", version = "1.15.3")
api(group = "com.squareup.okhttp3", name = "okhttp", version = "4.9.3")
api(group = "me.duncte123", name = "reliqua", version = "2.6.5") {
Expand Down
27 changes: 4 additions & 23 deletions src/main/java/me/duncte123/botcommons/messaging/MessageConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import me.duncte123.botcommons.StringUtils;
import me.duncte123.botcommons.commands.ICommandContext;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.MessageType;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
Expand All @@ -37,12 +39,9 @@
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;

public class MessageConfig {
private static Function<MessageChannel, String> nonceSupplier = (c) -> c.getId() + System.currentTimeMillis();

private final MessageChannel channel;
private final MessageCreateBuilder messageBuilder;
private final List<EmbedBuilder> embeds;
Expand Down Expand Up @@ -168,20 +167,6 @@ public Consumer<MessageCreateAction> getActionConfig() {
return this.actionConfig;
}

/**
* Sets the supplier for the nonce.<br/>
* A nonce can be used to verify if the message you recieve is the message you want
*
* @param nonceSupplier
* A function that returns the nonce, by default this is the {@link MessageChannel#getId() channel id} combined
* with the {@link System#currentTimeMillis() current time in milliseconds}
*/
public static void setNonceSupplier(Function<MessageChannel, String> nonceSupplier) {
Checks.notNull(nonceSupplier, "nonceSupplier");

MessageConfig.nonceSupplier = nonceSupplier;
}

/**
* Builder class for the message config
*/
Expand Down Expand Up @@ -656,11 +641,7 @@ public MessageConfig build() {
this.mentionRepliedUser,
this.failureAction,
this.successAction,
(config) -> {
// Set the nonce for the message
config.setNonce(nonceSupplier.apply(this.channel));
this.actionConfig.accept(config);
}
this.actionConfig
);
}

Expand Down

0 comments on commit a8d720e

Please sign in to comment.