Class OptionHelper

java.lang.Object
pw.chew.jdachewtils.command.OptionHelper

public final class OptionHelper extends Object
A collection of useful methods for working with Options.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    hasOption(@NotNull net.dv8tion.jda.api.events.interaction.SlashCommandEvent event, @NotNull String option)
    Checks to see if the event has an option.
    static boolean
    optBoolean(@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 double
    optDouble(@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.GuildChannel
    optGuildChannel(@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 long
    optLong(@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.Member
    optMember(@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.IMentionable
    optMentionable(@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.MessageChannel
    optMessageChannel(@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.Role
    optRole(@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 String
    optString(@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.User
    optUser(@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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 from
      option - The option we want
      defaultValue - 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 from
      option - The option we want
      defaultValue - 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 from
      option - The option we want
      defaultValue - 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 from
      option - The option we want
      defaultValue - 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 from
      option - The option we want
      defaultValue - 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 from
      option - The option we want
      defaultValue - 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 from
      option - The option we want
      defaultValue - 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 from
      option - The option we want
      defaultValue - 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 from
      option - The option we want
      defaultValue - 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 from
      option - The option we want
      defaultValue - 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 from
      option - the option we want
      Returns:
      true if the option exists, false otherwise