Class Interaction

java.lang.Object
discord4j.core.object.command.Interaction
All Implemented Interfaces:
DiscordObject

@Experimental public class Interaction extends Object implements DiscordObject
A Discord interaction.
See Also:
  • Constructor Details

    • Interaction

      public Interaction(GatewayDiscordClient gateway, discord4j.discordjson.json.InteractionData data)
      Constructs an Interaction with an associated GatewayDiscordClient and Discord data.
      Parameters:
      gateway - The GatewayDiscordClient associated to this object, must be non-null.
      data - The raw data as represented by Discord, must be non-null.
  • Method Details

    • getData

      public discord4j.discordjson.json.InteractionData getData()
    • getId

      public Snowflake getId()
      Gets the id of the interaction.
      Returns:
      The id of the interaction.
    • getApplicationId

      public Snowflake getApplicationId()
      Gets the id of the application this interaction is for.
      Returns:
      The id of the application this interaction is for.
    • getType

      public Interaction.Type getType()
      Gets the type of interaction.
      Returns:
      The type of interaction.
    • getCommandInteraction

      public Optional<ApplicationCommandInteraction> getCommandInteraction()
      Gets the command data payload.
      Returns:
      The command data payload.
    • getGuildId

      public Optional<Snowflake> getGuildId()
      Gets the guild id it was sent from, if invoked in a guild.
      Returns:
      The guild id it was sent from, if invoked in a guild.
    • getGuild

      public Mono<Guild> getGuild()
      Gets the guild it was sent from, if invoked in a guild.
      Returns:
      The guild it was sent from, if invoked in a guild.
    • getChannelId

      public Snowflake getChannelId()
      Gets the channel id it was sent from.
      Returns:
      The channel id it was sent from.
    • getChannel

      public Mono<MessageChannel> getChannel()
      Gets the channel it was sent from.
      Returns:
      The channel it was sent from.
    • getMember

      public Optional<Member> getMember()
      Gets the invoking member, if invoked in a guild.
      Returns:
      The invoking member, if invoked in a guild.
    • getUser

      public User getUser()
      Gets the invoking user. The user data is extracted from the member if invoked in a guild.
      Returns:
      The invoking user. The user data is extracted from the member if invoked in a guild.
    • getToken

      public String getToken()
      Gets the continuation token for responding to the interaction.
      Returns:
      The continuation token for responding to the interaction.
    • getMessage

      public Optional<Message> getMessage()
      Gets the message associated with the interaction.
      Returns:
      The message associated with the interaction.
    • getMessageId

      public Optional<Snowflake> getMessageId()
      Gets the ID of the message associated with the interaction.
      Returns:
      The message associated with the interaction.
    • getUserLocale

      public String getUserLocale()
      Gets the invoking user's client locale.
      This is not present on PING interactions and will therefore default to en-US
      Returns:
      The invoking user's client locale.
      See Also:
    • getGuildLocale

      public Optional<String> getGuildLocale()
      Gets the guild's locale if the interaction was invoked from a guild. Defaults to en-US for non-community guilds.
      This is not present on PING interactions
      Returns:
      The locale of the guild where the interaction was invoked, otherwise Optional.empty()
      See Also:
    • getClient

      public GatewayDiscordClient getClient()
      Description copied from interface: DiscordObject
      Returns the GatewayDiscordClient that created this object. Methods in it are exclusively based on the entity cache or Store in use. Refer to calling getClient().rest() to access a DiscordClient that is capable of requesting entities directly from the REST API.
      Specified by:
      getClient in interface DiscordObject
      Returns:
      The GatewayDiscordClient associated to this object.