diff --git a/src/main/java/net/dv8tion/jda/api/interactions/ICustomIdInteraction.java b/src/main/java/net/dv8tion/jda/api/interactions/ICustomIdInteraction.java new file mode 100644 index 0000000000..28c27b7c40 --- /dev/null +++ b/src/main/java/net/dv8tion/jda/api/interactions/ICustomIdInteraction.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.dv8tion.jda.api.interactions; + +import net.dv8tion.jda.api.interactions.components.ComponentInteraction; +import net.dv8tion.jda.api.interactions.modals.ModalInteraction; + +import javax.annotation.Nonnull; + +/** + * Marker interface for interactions with custom IDs. + * + *
This includes modals and components.
+ */
+public interface ICustomIdInteraction
+{
+ /**
+ * The relevant custom ID, that has been provided for the component or modal when it was originally created.
+ *
This value should be used to determine what action to take in regard to this interaction.
+ *
+ *
This id does not have to be numerical.
+ *
+ * @return The custom ID
+ *
+ * @see ComponentInteraction#getComponentId()
+ * @see ModalInteraction#getModalId()
+ */
+ @Nonnull
+ String getCustomId();
+}
diff --git a/src/main/java/net/dv8tion/jda/api/interactions/components/ComponentInteraction.java b/src/main/java/net/dv8tion/jda/api/interactions/components/ComponentInteraction.java
index 2b2290c213..a17baf8505 100644
--- a/src/main/java/net/dv8tion/jda/api/interactions/components/ComponentInteraction.java
+++ b/src/main/java/net/dv8tion/jda/api/interactions/components/ComponentInteraction.java
@@ -19,6 +19,7 @@
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.channel.unions.GuildMessageChannelUnion;
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
+import net.dv8tion.jda.api.interactions.ICustomIdInteraction;
import net.dv8tion.jda.api.interactions.callbacks.IMessageEditCallback;
import net.dv8tion.jda.api.interactions.callbacks.IModalCallback;
import net.dv8tion.jda.api.interactions.callbacks.IPremiumRequiredReplyCallback;
@@ -32,8 +33,16 @@
*
Instead of {@link #deferReply()} and {@link #reply(String)} you can use {@link #deferEdit()} and {@link #editMessage(String)} with these interactions!
* You can only acknowledge an interaction once!
*/
-public interface ComponentInteraction extends IReplyCallback, IMessageEditCallback, IModalCallback, IPremiumRequiredReplyCallback
+public interface ComponentInteraction extends IReplyCallback, IMessageEditCallback, IModalCallback, IPremiumRequiredReplyCallback, ICustomIdInteraction
{
+
+ @Override
+ @Nonnull
+ default String getCustomId()
+ {
+ return getComponentId();
+ }
+
/**
* The custom component ID provided to the component when it was originally created.
*
This value should be used to determine what action to take in regard to this interaction.
diff --git a/src/main/java/net/dv8tion/jda/api/interactions/modals/ModalInteraction.java b/src/main/java/net/dv8tion/jda/api/interactions/modals/ModalInteraction.java
index f602cdc82f..c029e03e13 100644
--- a/src/main/java/net/dv8tion/jda/api/interactions/modals/ModalInteraction.java
+++ b/src/main/java/net/dv8tion/jda/api/interactions/modals/ModalInteraction.java
@@ -19,6 +19,7 @@
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.channel.unions.GuildMessageChannelUnion;
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
+import net.dv8tion.jda.api.interactions.ICustomIdInteraction;
import net.dv8tion.jda.api.interactions.callbacks.IMessageEditCallback;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.internal.utils.Checks;
@@ -36,8 +37,16 @@
*
* @see net.dv8tion.jda.api.events.interaction.ModalInteractionEvent
*/
-public interface ModalInteraction extends IReplyCallback, IMessageEditCallback
+public interface ModalInteraction extends IReplyCallback, IMessageEditCallback, ICustomIdInteraction
{
+
+ @Override
+ @Nonnull
+ default String getCustomId()
+ {
+ return getModalId();
+ }
+
/**
* Returns the custom id of the Modal in question
*