fr.alexpado.jda.interactions.meta.InteractionMeta Maven / Gradle / Ivy
package fr.alexpado.jda.interactions.meta;
import fr.alexpado.jda.interactions.annotations.Interact;
import fr.alexpado.jda.interactions.enums.SlashTarget;
import fr.alexpado.jda.interactions.interfaces.interactions.InteractionTarget;
import net.dv8tion.jda.api.interactions.Interaction;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import java.util.List;
/**
* Class version of the annotation {@link Interact}.
*/
public class InteractionMeta {
private final String name;
private final String description;
private final SlashTarget target;
private final List options;
private final boolean hide;
private final boolean defer;
private final boolean reply;
/**
* Create a new {@link InteractionMeta}.
*
* @param name
* The interaction name (path).
* @param description
* The interaction description.
* @param target
* The interaction target.
* @param options
* The interaction {@link OptionMeta} list.
* @param hide
* Define if the response generated by the {@link InteractionTarget} to which this {@link InteractionMeta}
* is attached should be hidden. A hidden response will only be displayed to the issuer of the
* {@link Interaction}.
* @param defer
* Define if the response might take a while to be generated. If true, the response will be deferred.
* @param reply
* Define if the response will create a new message or edit the original.
*/
public InteractionMeta(String name, String description, SlashTarget target, List options, boolean hide, boolean defer, boolean reply) {
this.name = name;
this.description = description;
this.target = target;
this.options = options;
this.hide = hide;
this.defer = defer;
this.reply = reply;
}
/**
* Retrieve this {@link InteractionMeta} name
*
* @return The name
*/
public String getName() {
return this.name;
}
/**
* Retrieve this {@link InteractionMeta} description
*
* @return The description
*/
public String getDescription() {
return this.description;
}
/**
* Retrieve this {@link InteractionMeta} {@link SlashTarget}.
*
* @return A {@link SlashTarget}
*/
public SlashTarget getTarget() {
return this.target;
}
/**
* Retrieve this {@link InteractionMeta} list of {@link OptionMeta}.
*
* @return A {@link OptionMeta} list
*/
public List getOptions() {
return this.options;
}
/**
* Check if the {@link InteractionTarget} to which this {@link InteractionMeta} is attached should only display its
* result to the user who ran the {@link Interaction}.
*
* @return True if only displayed for the user, false otherwise.
*/
public boolean isHidden() {
return this.hide;
}
/**
* Check if the {@link IReplyCallback} should be deferred due to the nature of the execution of the
* {@link InteractionTarget} to which this {@link InteractionMeta} is attached.
*
* @return True if the result should be deferred, false otherwise.
*/
public boolean isDeferred() {
return this.defer;
}
/**
* Define if the response will create a new message or edit the original.
*
* @return True if a new message should be created, false otherwise.
*/
public boolean shouldReply() {
return this.reply;
}
}