Package discord4j.core.object.command
Class Interaction
java.lang.Object
discord4j.core.object.command.Interaction
- All Implemented Interfaces:
DiscordObject
A Discord interaction.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Represents the various types of interaction. -
Constructor Summary
ConstructorDescriptionInteraction
(GatewayDiscordClient gateway, discord4j.discordjson.json.InteractionData data) Constructs anInteraction
with an associatedGatewayDiscordClient
and Discord data. -
Method Summary
Modifier and TypeMethodDescriptionGets the id of the application this interaction is for.Gets the channel it was sent from.Gets the channel id it was sent from.Returns theGatewayDiscordClient
that created this object.Gets the command data payload.discord4j.discordjson.json.InteractionData
getData()
getGuild()
Gets the guild it was sent from, if invoked in a guild.Gets the guild id it was sent from, if invoked in a guild.Gets the guild's locale if the interaction was invoked from a guild.getId()
Gets the id of the interaction.Gets the invoking member, if invoked in a guild.Gets the message associated with the interaction.Gets the ID of the message associated with the interaction.getToken()
Gets the continuation token for responding to the interaction.getType()
Gets the type of interaction.getUser()
Gets the invoking user.Gets the invoking user's client locale.
-
Constructor Details
-
Interaction
Constructs anInteraction
with an associatedGatewayDiscordClient
and Discord data.- Parameters:
gateway
- TheGatewayDiscordClient
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
Gets the id of the interaction.- Returns:
- The id of the interaction.
-
getApplicationId
Gets the id of the application this interaction is for.- Returns:
- The id of the application this interaction is for.
-
getType
Gets the type of interaction.- Returns:
- The type of interaction.
-
getCommandInteraction
Gets the command data payload.- Returns:
- The command data payload.
-
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
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
Gets the channel id it was sent from.- Returns:
- The channel id it was sent from.
-
getChannel
Gets the channel it was sent from.- Returns:
- The channel it was sent from.
-
getMember
Gets the invoking member, if invoked in a guild.- Returns:
- The invoking member, if invoked in a guild.
-
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
Gets the continuation token for responding to the interaction.- Returns:
- The continuation token for responding to the interaction.
-
getMessage
Gets the message associated with the interaction.- Returns:
- The message associated with the interaction.
-
getMessageId
Gets the ID of the message associated with the interaction.- Returns:
- The message associated with the interaction.
-
getUserLocale
Gets the invoking user's client locale.
This is not present onPING
interactions and will therefore default toen-US
- Returns:
- The invoking user's client locale.
- See Also:
-
getGuildLocale
Gets the guild's locale if the interaction was invoked from a guild. Defaults toen-US
for non-community guilds.
This is not present onPING
interactions- Returns:
- The locale of the guild where the interaction was invoked, otherwise
Optional.empty()
- See Also:
-
getClient
Description copied from interface:DiscordObject
Returns theGatewayDiscordClient
that created this object. Methods in it are exclusively based on the entity cache orStore
in use. Refer to callinggetClient().rest()
to access aDiscordClient
that is capable of requesting entities directly from the REST API.- Specified by:
getClient
in interfaceDiscordObject
- Returns:
- The
GatewayDiscordClient
associated to this object.
-