From 0cc30ddf29a94a5f36bddc90b46a5be913fc1400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Sun, 15 Jan 2023 05:29:57 +0100 Subject: [PATCH] Implement MessageRespone base functions --- .../hidekobot/objects/MessageResponse.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main/java/wtf/beatrice/hidekobot/objects/MessageResponse.java b/src/main/java/wtf/beatrice/hidekobot/objects/MessageResponse.java index ec3f28c..4b91bba 100644 --- a/src/main/java/wtf/beatrice/hidekobot/objects/MessageResponse.java +++ b/src/main/java/wtf/beatrice/hidekobot/objects/MessageResponse.java @@ -4,8 +4,37 @@ import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.interactions.components.ItemComponent; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; +import java.util.Objects; + public record MessageResponse(@Nullable String content, @Nullable MessageEmbed embed, @Nullable ItemComponent... components) { + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MessageResponse response = (MessageResponse) o; + return Objects.equals(content, response.content) && + Objects.equals(embed, response.embed) && + Arrays.equals(components, response.components); + } + + @Override + public int hashCode() { + int result = Objects.hash(content, embed); + result = 31 * result + Arrays.hashCode(components); + return result; + } + + @Override + public String toString() { + return "MessageResponse{" + + "content=" + content + + ", embed=" + embed + + ", components=" + Arrays.toString(components) + + '}'; + } }