Package pw.chew.jdachewtils.command
Class OptionHelper
java.lang.Object
pw.chew.jdachewtils.command.OptionHelper
A collection of useful methods for working with Options.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanhasOption(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option) Checks to see if the event has an option.static booleanoptBoolean(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option, boolean defaultValue) Guarantees a boolean option value by providing a default value.static doubleoptDouble(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option, double defaultValue) Guarantees a double option value by providing a default value.static @Nullable net.dv8tion.jda.api.entities.GuildChanneloptGuildChannel(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option, @Nullable net.dv8tion.jda.api.entities.GuildChannel defaultValue) Guarantees a Guild Channel option value by providing a default value.static longoptLong(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option, long defaultValue) Guarantees a long option value by providing a default value.static @Nullable net.dv8tion.jda.api.entities.MemberoptMember(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option, @Nullable net.dv8tion.jda.api.entities.Member defaultValue) Guarantees a Member option value by providing a default value.static @Nullable net.dv8tion.jda.api.entities.IMentionableoptMentionable(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option, @Nullable net.dv8tion.jda.api.entities.IMentionable defaultValue) Guarantees a IMentionable option value by providing a default value.static @Nullable net.dv8tion.jda.api.entities.MessageChanneloptMessageChannel(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option, @Nullable net.dv8tion.jda.api.entities.MessageChannel defaultValue) Guarantees a MessageChannel option value by providing a default value.static @Nullable net.dv8tion.jda.api.entities.RoleoptRole(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option, @Nullable net.dv8tion.jda.api.entities.Role defaultValue) Guarantees a Role option value by providing a default value.static @Nullable StringoptString(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option, @Nullable String defaultValue) Guarantees a String option value by providing a default value.static @Nullable net.dv8tion.jda.api.entities.UseroptUser(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option, @Nullable net.dv8tion.jda.api.entities.User defaultValue) Guarantees a User option value by providing a default value.
-
Method Details
-
optString
@Nullable @Contract("_, _, !null -> !null") public static @Nullable String optString(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option, @Nullable @Nullable String defaultValue) Guarantees a String option value by providing a default value.- Parameters:
event- The slash command event to get options fromoption- 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
-
optBoolean
public static boolean optBoolean(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option, boolean defaultValue) Guarantees a boolean option value by providing a default value.- Parameters:
event- The slash command event to get options fromoption- 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
public static long optLong(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option, long defaultValue) Guarantees a long option value by providing a default value.- Parameters:
event- The slash command event to get options fromoption- 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
public static double optDouble(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option, double defaultValue) Guarantees a double option value by providing a default value.- Parameters:
event- The slash command event to get options fromoption- 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 @Contract("_, _, !null -> !null") public static @Nullable net.dv8tion.jda.api.entities.GuildChannel optGuildChannel(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option, @Nullable @Nullable net.dv8tion.jda.api.entities.GuildChannel defaultValue) Guarantees a Guild Channel option value by providing a default value.- Parameters:
event- The slash command event to get options fromoption- 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
-
optMember
@Nullable @Contract("_, _, !null -> !null") public static @Nullable net.dv8tion.jda.api.entities.Member optMember(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option, @Nullable @Nullable net.dv8tion.jda.api.entities.Member defaultValue) Guarantees a Member option value by providing a default value.- Parameters:
event- The slash command event to get options fromoption- 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
-
optMentionable
@Nullable @Contract("_, _, !null -> !null") public static @Nullable net.dv8tion.jda.api.entities.IMentionable optMentionable(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option, @Nullable @Nullable net.dv8tion.jda.api.entities.IMentionable defaultValue) Guarantees a IMentionable option value by providing a default value.- Parameters:
event- The slash command event to get options fromoption- 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
-
optRole
@Nullable @Contract("_, _, !null -> !null") public static @Nullable net.dv8tion.jda.api.entities.Role optRole(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option, @Nullable @Nullable net.dv8tion.jda.api.entities.Role defaultValue) Guarantees a Role option value by providing a default value.- Parameters:
event- The slash command event to get options fromoption- 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
-
optUser
@Nullable @Contract("_, _, !null -> !null") public static @Nullable net.dv8tion.jda.api.entities.User optUser(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option, @Nullable @Nullable net.dv8tion.jda.api.entities.User defaultValue) Guarantees a User option value by providing a default value.- Parameters:
event- The slash command event to get options fromoption- 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
-
optMessageChannel
@Nullable @Contract("_, _, !null -> !null") public static @Nullable net.dv8tion.jda.api.entities.MessageChannel optMessageChannel(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option, @Nullable @Nullable net.dv8tion.jda.api.entities.MessageChannel defaultValue) Guarantees a MessageChannel option value by providing a default value.- Parameters:
event- The slash command event to get options fromoption- 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
-
hasOption
public static boolean hasOption(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull @NotNull String option) Checks to see if the event has an option.- Parameters:
event- the slash command event to get options fromoption- the option we want- Returns:
- true if the option exists, false otherwise
-