Package com.jagrosh.jdautilities.command
Class SlashCommandEvent
java.lang.Object
net.dv8tion.jda.api.events.Event
net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent
net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
com.jagrosh.jdautilities.command.SlashCommandEvent
- All Implemented Interfaces:
net.dv8tion.jda.api.entities.ISnowflake,net.dv8tion.jda.api.events.GenericEvent,net.dv8tion.jda.api.interactions.callbacks.IDeferrableCallback,net.dv8tion.jda.api.interactions.callbacks.IModalCallback,net.dv8tion.jda.api.interactions.callbacks.IReplyCallback,net.dv8tion.jda.api.interactions.commands.CommandInteraction,net.dv8tion.jda.api.interactions.commands.CommandInteractionPayload,net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction,net.dv8tion.jda.api.interactions.Interaction
public class SlashCommandEvent
extends net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
A wrapper class for a
SlashCommandInteractionEvent and CommandClient.
From here, developers can invoke several useful and specialized methods to assist in Command function and development. Because this extends SlashCommandInteractionEvent, all methods from it work fine.
- Author:
- Olivia (Chew)
-
Field Summary
Fields inherited from class net.dv8tion.jda.api.events.Event
api, rawData, responseNumber -
Constructor Summary
ConstructorsConstructorDescriptionSlashCommandEvent(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event, CommandClient client) -
Method Summary
Modifier and TypeMethodDescriptionTheCommandClientthat this event was triggered from.net.dv8tion.jda.api.entities.channel.concrete.TextChannelGets theTextChannelthat this CommandEvent may have taken place on, ornullif it didn't happen on a TextChannel.booleanWill return if the provided key resolves into a provided Option for the SlashCommand.booleanisFromType(net.dv8tion.jda.api.entities.channel.ChannelType channelType) Compares a providedChannelTypewith the one this event occurred on, returningtrueif they are the same ChannelType.net.dv8tion.jda.api.entities.Message.AttachmentoptAttachment(String key) Gets the provided Option Key as an Attachment value, or returnsnullif the option cannot be found.net.dv8tion.jda.api.entities.Message.AttachmentoptAttachment(String key, net.dv8tion.jda.api.entities.Message.Attachment defaultValue) Gets the provided Option Key as an Attachment value, or returns the default one if the option cannot be found.booleanoptBoolean(String key) Gets the provided Option Key as a boolean value, or returnsfalseif the option cannot be found.booleanoptBoolean(String key, boolean defaultValue) Gets the provided Option Key as a boolean value, or returns the default one if the option cannot be found.doubleGets the provided Option Key as a double value, or returns0.0if the option cannot be found.doubleGets the provided Option Key as a double value, or returns the default one if the option cannot be found.net.dv8tion.jda.api.entities.channel.middleman.GuildChanneloptGuildChannel(String key) Gets the provided Option Key as a GuildChannel value, or returnsnullif the option cannot be found.net.dv8tion.jda.api.entities.channel.middleman.GuildChanneloptGuildChannel(String key, net.dv8tion.jda.api.entities.channel.middleman.GuildChannel defaultValue) Gets the provided Option Key as a GuildChannel value, or returns the default one if the option cannot be found.longGets the provided Option Key as a long value, or returns0if the option cannot be found.longGets the provided Option Key as a long value, or returns the default one if the option cannot be found.net.dv8tion.jda.api.entities.MemberGets the provided Option Key as a Member value, or returnsnullif the option cannot be found.net.dv8tion.jda.api.entities.MemberGets the provided Option Key as a Member value, or returns the default one if the option cannot be found.net.dv8tion.jda.api.entities.IMentionableoptMentionable(String key) Gets the provided Option Key as a IMentionable value, or returnsnullif the option cannot be found.net.dv8tion.jda.api.entities.IMentionableoptMentionable(String key, net.dv8tion.jda.api.entities.IMentionable defaultValue) Gets the provided Option Key as a IMentionable value, or returns the default one if the option cannot be found.net.dv8tion.jda.api.entities.channel.middleman.MessageChanneloptMessageChannel(String key) Gets the provided Option Key as a MessageChannel value, or returnsnullif the option cannot be found.net.dv8tion.jda.api.entities.channel.middleman.MessageChanneloptMessageChannel(String key, net.dv8tion.jda.api.entities.channel.middleman.MessageChannel defaultValue) Gets the provided Option Key as a MessageChannel value, or returns the default one if the option cannot be found.net.dv8tion.jda.api.entities.RoleGets the provided Option Key as a Role value, or returnsnullif the option cannot be found.net.dv8tion.jda.api.entities.RoleGets the provided Option Key as a Role value, or returns the default one if the option cannot be found.Gets the provided Option Key as a String value, or returnsnullif the option cannot be found.Gets the provided Option Key as a String value, or returns the default one if the option cannot be found.net.dv8tion.jda.api.entities.UserGets the provided Option Key as a User value, or returnsnullif the option cannot be found.net.dv8tion.jda.api.entities.UserGets the provided Option Key as a User value, or returns the default one if the option cannot be found.Methods inherited from class net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
getChannel, getInteractionMethods inherited from class net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent
deferReply, getCommandIdLong, getCommandType, getHook, getName, getOptions, getSubcommandGroup, getSubcommandName, isGuildCommand, replyModalMethods inherited from class net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
getGuild, getGuildLocale, getIdLong, getMember, getToken, getTypeRaw, getUser, getUserLocale, isAcknowledgedMethods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getRawData, getResponseNumber, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.dv8tion.jda.api.interactions.commands.CommandInteractionPayload
getCommandId, getCommandIdLong, getCommandString, getCommandType, getFullCommandName, getName, getOption, getOption, getOption, getOption, getOptions, getOptionsByName, getOptionsByType, getSubcommandGroup, getSubcommandName, isGlobalCommand, isGuildCommandMethods inherited from interface net.dv8tion.jda.api.interactions.callbacks.IDeferrableCallback
getHookMethods inherited from interface net.dv8tion.jda.api.interactions.callbacks.IModalCallback
replyModalMethods inherited from interface net.dv8tion.jda.api.interactions.Interaction
getChannelType, getGuild, getGuildLocale, getJDA, getMember, getMessageChannel, getToken, getType, getTypeRaw, getUser, getUserLocale, isAcknowledged, isFromGuildMethods inherited from interface net.dv8tion.jda.api.interactions.callbacks.IReplyCallback
deferReply, deferReply, reply, reply, replyComponents, replyComponents, replyEmbeds, replyEmbeds, replyFiles, replyFiles, replyFormatMethods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreatedMethods inherited from interface net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction
getGuildChannel
-
Constructor Details
-
SlashCommandEvent
public SlashCommandEvent(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event, CommandClient client)
-
-
Method Details
-
getClient
TheCommandClientthat this event was triggered from.- Returns:
- The CommandClient that this event was triggered from
-
optString
Gets the provided Option Key as a String value, or returnsnullif the option cannot be found.- Parameters:
key- The option we want- Returns:
- The provided option, or null if the option is not present
-
optString
@Nullable @Contract("_, !null -> !null") public String optString(@NotNull String key, @Nullable String defaultValue) Gets the provided Option Key as a String value, or returns the default one if the option cannot be found.- Parameters:
key- The option we wantdefaultValue- Nullable default value used in the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
optBoolean
Gets the provided Option Key as a boolean value, or returnsfalseif the option cannot be found.- Parameters:
key- The option we want- Returns:
- The provided option, or false if the option is not present
-
optBoolean
Gets the provided Option Key as a boolean value, or returns the default one if the option cannot be found.- Parameters:
key- The option we wantdefaultValue- The fallback option in case of the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
optLong
Gets the provided Option Key as a long value, or returns0if the option cannot be found.- Parameters:
key- The option we want- Returns:
- The provided option, or 0 if the option is not present
-
optLong
Gets the provided Option Key as a long value, or returns the default one if the option cannot be found.- Parameters:
key- The option we wantdefaultValue- The fallback option in case of the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
optDouble
Gets the provided Option Key as a double value, or returns0.0if the option cannot be found.- Parameters:
key- The option we want- Returns:
- The provided option, or 0.0 if the option is not present
-
optDouble
Gets the provided Option Key as a double value, or returns the default one if the option cannot be found.- Parameters:
key- The option we wantdefaultValue- The fallback option in case of the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
optGuildChannel
@Nullable public net.dv8tion.jda.api.entities.channel.middleman.GuildChannel optGuildChannel(@NotNull String key) Gets the provided Option Key as a GuildChannel value, or returnsnullif the option cannot be found.
This will always return null when the SlashCommandEvent was not executed in a Guild.- Parameters:
key- The option we want- Returns:
- The provided option, or null if the option is not present
-
optGuildChannel
@Nullable @Contract("_, !null -> !null") public net.dv8tion.jda.api.entities.channel.middleman.GuildChannel optGuildChannel(@NotNull String key, @Nullable net.dv8tion.jda.api.entities.channel.middleman.GuildChannel defaultValue) Gets the provided Option Key as a GuildChannel value, or returns the default one if the option cannot be found.
This will always return the default value when the SlashCommandEvent was not executed in a Guild.- Parameters:
key- The option we wantdefaultValue- Nullable default value used in the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
optMember
Gets the provided Option Key as a Member value, or returnsnullif the option cannot be found.
This will always return null when the SlashCommandEvent was not executed in a Guild.- Parameters:
key- The option we want- Returns:
- The provided option, or null if the option is not present
-
optMember
@Nullable @Contract("_, !null -> !null") public net.dv8tion.jda.api.entities.Member optMember(@NotNull String key, @Nullable net.dv8tion.jda.api.entities.Member defaultValue) Gets the provided Option Key as a Member value, or returns the default one if the option cannot be found.
This will always return the default value when the SlashCommandEvent was not executed in a Guild.- Parameters:
key- The option we wantdefaultValue- Nullable default value used in the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
optMentionable
Gets the provided Option Key as a IMentionable value, or returnsnullif the option cannot be found.- Parameters:
key- The option we want- Returns:
- The provided option, or null if the option is not present
-
optMentionable
@Nullable @Contract("_, !null -> !null") public net.dv8tion.jda.api.entities.IMentionable optMentionable(@NotNull String key, @Nullable net.dv8tion.jda.api.entities.IMentionable defaultValue) Gets the provided Option Key as a IMentionable value, or returns the default one if the option cannot be found.- Parameters:
key- The option we wantdefaultValue- Nullable default value used in the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
optRole
Gets the provided Option Key as a Role value, or returnsnullif the option cannot be found.
This will always return null when the SlashCommandEvent was not executed in a Guild.- Parameters:
key- The option we want- Returns:
- The provided option, or null if the option is not present
-
optRole
@Nullable @Contract("_, !null -> !null") public net.dv8tion.jda.api.entities.Role optRole(@NotNull String key, @Nullable net.dv8tion.jda.api.entities.Role defaultValue) Gets the provided Option Key as a Role value, or returns the default one if the option cannot be found.
This will always return the default value when the SlashCommandEvent was not executed in a Guild.- Parameters:
key- The option we wantdefaultValue- Nullable default value used in the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
optUser
Gets the provided Option Key as a User value, or returnsnullif the option cannot be found.- Parameters:
key- The option we want- Returns:
- The provided option, or null if the option is not present
-
optUser
@Nullable @Contract("_, !null -> !null") public net.dv8tion.jda.api.entities.User optUser(@NotNull String key, @Nullable net.dv8tion.jda.api.entities.User defaultValue) Gets the provided Option Key as a User value, or returns the default one if the option cannot be found.- Parameters:
key- The option we wantdefaultValue- Nullable default value used in the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
optMessageChannel
@Nullable public net.dv8tion.jda.api.entities.channel.middleman.MessageChannel optMessageChannel(@NotNull String key) Gets the provided Option Key as a MessageChannel value, or returnsnullif the option cannot be found.- Parameters:
key- The option we want- Returns:
- The provided option, or null if the option is not present
-
optMessageChannel
@Nullable @Contract("_, !null -> !null") public net.dv8tion.jda.api.entities.channel.middleman.MessageChannel optMessageChannel(@NotNull String key, @Nullable net.dv8tion.jda.api.entities.channel.middleman.MessageChannel defaultValue) Gets the provided Option Key as a MessageChannel value, or returns the default one if the option cannot be found.- Parameters:
key- The option we wantdefaultValue- Nullable default value used in the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
optAttachment
Gets the provided Option Key as an Attachment value, or returnsnullif the option cannot be found.- Parameters:
key- The option we want- Returns:
- The provided option, or the default value if the option is not present
-
optAttachment
@Nullable @Contract("_, !null -> !null") public net.dv8tion.jda.api.entities.Message.Attachment optAttachment(@NotNull String key, @Nullable net.dv8tion.jda.api.entities.Message.Attachment defaultValue) Gets the provided Option Key as an Attachment value, or returns the default one if the option cannot be found.- Parameters:
key- The option we wantdefaultValue- Nullable default value used in the absence of the option value- Returns:
- The provided option, or the default value if the option is not present
-
hasOption
Will return if the provided key resolves into a provided Option for the SlashCommand.- Parameters:
key- the option we want- Returns:
- true if the option exists, false otherwise
-
isFromType
public boolean isFromType(net.dv8tion.jda.api.entities.channel.ChannelType channelType) Compares a providedChannelTypewith the one this event occurred on, returningtrueif they are the same ChannelType.- Parameters:
channelType- The ChannelType to compare- Returns:
trueif the CommandEvent originated from aMessageChannelof the provided ChannelType, otherwisefalse.
-
getTextChannel
public net.dv8tion.jda.api.entities.channel.concrete.TextChannel getTextChannel()Gets theTextChannelthat this CommandEvent may have taken place on, ornullif it didn't happen on a TextChannel.- Returns:
- The TextChannel this CommandEvent may have taken place on, or null if it did not happen on a TextChannel.
-