Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common interface for interactions with a custom ID #2778

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.dv8tion.jda.api.interactions;
Kaktushose marked this conversation as resolved.
Show resolved Hide resolved

import net.dv8tion.jda.api.interactions.components.ComponentInteraction;
import net.dv8tion.jda.api.interactions.modals.ModalInteraction;

import javax.annotation.Nonnull;

/**
* Interactions which have a custom ID, namely {@link ComponentInteraction} and {@link ModalInteraction}.
*
* <br>This id does not have to be numerical.
*
Kaktushose marked this conversation as resolved.
Show resolved Hide resolved
*/
public interface CustomIdInteraction
Kaktushose marked this conversation as resolved.
Show resolved Hide resolved
{
/**
* The custom ID provided to the component or modal when it was originally created.
Kaktushose marked this conversation as resolved.
Show resolved Hide resolved
* <br>This value should be used to determine what action to take in regard to this interaction.
MinnDevelopment marked this conversation as resolved.
Show resolved Hide resolved
*
* <br>This id does not have to be numerical.
MinnDevelopment marked this conversation as resolved.
Show resolved Hide resolved
*
* @return The custom ID
*
* @see ComponentInteraction#getComponentId()
* @see ModalInteraction#getModalId()
*/
@Nonnull
String getCustomId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.CustomIdInteraction;
import net.dv8tion.jda.api.interactions.callbacks.IMessageEditCallback;
import net.dv8tion.jda.api.interactions.callbacks.IModalCallback;
import net.dv8tion.jda.api.interactions.callbacks.IPremiumRequiredReplyCallback;
Expand All @@ -32,8 +33,16 @@
* <p>Instead of {@link #deferReply()} and {@link #reply(String)} you can use {@link #deferEdit()} and {@link #editMessage(String)} with these interactions!
* <b>You can only acknowledge an interaction once!</b>
*/
public interface ComponentInteraction extends IReplyCallback, IMessageEditCallback, IModalCallback, IPremiumRequiredReplyCallback
public interface ComponentInteraction extends IReplyCallback, IMessageEditCallback, IModalCallback, IPremiumRequiredReplyCallback, CustomIdInteraction
{

@Override
@Nonnull
default String getCustomId()
{
return getComponentId();
}

/**
* The custom component ID provided to the component when it was originally created.
* <br>This value should be used to determine what action to take in regard to this interaction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.CustomIdInteraction;
import net.dv8tion.jda.api.interactions.callbacks.IMessageEditCallback;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.internal.utils.Checks;
Expand All @@ -36,8 +37,16 @@
*
* @see net.dv8tion.jda.api.events.interaction.ModalInteractionEvent
*/
public interface ModalInteraction extends IReplyCallback, IMessageEditCallback
public interface ModalInteraction extends IReplyCallback, IMessageEditCallback, CustomIdInteraction
{

@Override
@Nonnull
default String getCustomId()
{
return getModalId();
}

/**
* Returns the custom id of the Modal in question
*
Expand Down
Loading