Search in sources :

Example 1 with InteractionImpl

use of net.dv8tion.jda.internal.interactions.InteractionImpl in project JDA by DV8FromTheWorld.

the class InteractionCreateHandler method handleInternally.

@Override
protected Long handleInternally(DataObject content) {
    int type = content.getInt("type");
    if (content.getInt("version", 1) != 1) {
        WebSocketClient.LOG.debug("Received interaction with version {}. This version is currently unsupported by this version of JDA. Consider updating!", content.getInt("version", 1));
        return null;
    }
    long guildId = content.getUnsignedLong("guild_id", 0);
    if (api.getGuildSetupController().isLocked(guildId))
        return guildId;
    if (guildId != 0 && api.getGuildById(guildId) == null)
        // discard event if it is not from a guild we are currently in
        return null;
    switch(InteractionType.fromKey(type)) {
        case // slash commands
        COMMAND:
            handleCommand(content);
            break;
        case // buttons/components
        COMPONENT:
            handleAction(content);
            break;
        case COMMAND_AUTOCOMPLETE:
            api.handleEvent(new CommandAutoCompleteInteractionEvent(api, responseNumber, new CommandAutoCompleteInteractionImpl(api, content)));
            break;
        default:
            api.handleEvent(new GenericInteractionCreateEvent(api, responseNumber, new InteractionImpl(api, content)));
    }
    return null;
}
Also used : GenericInteractionCreateEvent(net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent) UserContextInteractionImpl(net.dv8tion.jda.internal.interactions.command.UserContextInteractionImpl) SlashCommandInteractionImpl(net.dv8tion.jda.internal.interactions.command.SlashCommandInteractionImpl) InteractionImpl(net.dv8tion.jda.internal.interactions.InteractionImpl) MessageContextInteractionImpl(net.dv8tion.jda.internal.interactions.command.MessageContextInteractionImpl) ButtonInteractionImpl(net.dv8tion.jda.internal.interactions.component.ButtonInteractionImpl) SelectMenuInteractionImpl(net.dv8tion.jda.internal.interactions.component.SelectMenuInteractionImpl) CommandAutoCompleteInteractionImpl(net.dv8tion.jda.internal.interactions.command.CommandAutoCompleteInteractionImpl) CommandAutoCompleteInteractionImpl(net.dv8tion.jda.internal.interactions.command.CommandAutoCompleteInteractionImpl) CommandAutoCompleteInteractionEvent(net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent)

Aggregations

GenericInteractionCreateEvent (net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent)1 CommandAutoCompleteInteractionEvent (net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent)1 InteractionImpl (net.dv8tion.jda.internal.interactions.InteractionImpl)1 CommandAutoCompleteInteractionImpl (net.dv8tion.jda.internal.interactions.command.CommandAutoCompleteInteractionImpl)1 MessageContextInteractionImpl (net.dv8tion.jda.internal.interactions.command.MessageContextInteractionImpl)1 SlashCommandInteractionImpl (net.dv8tion.jda.internal.interactions.command.SlashCommandInteractionImpl)1 UserContextInteractionImpl (net.dv8tion.jda.internal.interactions.command.UserContextInteractionImpl)1 ButtonInteractionImpl (net.dv8tion.jda.internal.interactions.component.ButtonInteractionImpl)1 SelectMenuInteractionImpl (net.dv8tion.jda.internal.interactions.component.SelectMenuInteractionImpl)1