From bef34ee54849dcdb4e1012c642ad9983b98250f5 Mon Sep 17 00:00:00 2001 From: Tueem Date: Tue, 3 Dec 2024 20:20:57 +0100 Subject: [PATCH] fix null issue --- .../ExecutableSlashCommandDefinition.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableSlashCommandDefinition.java b/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableSlashCommandDefinition.java index 933a4a0..e110098 100644 --- a/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableSlashCommandDefinition.java +++ b/lib/src/main/java/net/tomatentum/marinara/interaction/commands/ExecutableSlashCommandDefinition.java @@ -16,9 +16,18 @@ public record ExecutableSlashCommandDefinition( if (!(o instanceof ExecutableSlashCommandDefinition)) return false; ExecutableSlashCommandDefinition other = (ExecutableSlashCommandDefinition) o; - return other.applicationCommand.name().equals(this.applicationCommand.name()) && - other.subCommandGroup.name().equals(this.subCommandGroup.name()) && - other.subCommand.name().equals(this.subCommand.name()); + boolean equals = false; + + if (this.applicationCommand() != null && other.subCommandGroup() != null) + equals = this.applicationCommand.name().equals(other.applicationCommand().name()); + + if (this.subCommandGroup() != null && other.subCommandGroup() != null) + equals = this.subCommandGroup().name().equals(other.subCommandGroup().name()); + + if (this.subCommand() != null && other.subCommand() != null) + equals = this.subCommand().name().equals(other.subCommand().name()); + + return equals; } @Override