Search in sources :

Example 1 with GuildInviteDeleteEvent

use of net.dv8tion.jda.api.events.guild.invite.GuildInviteDeleteEvent in project JDA by DV8FromTheWorld.

the class InviteDeleteHandler method handleInternally.

@Override
protected Long handleInternally(DataObject content) {
    long guildId = content.getUnsignedLong("guild_id");
    if (getJDA().getGuildSetupController().isLocked(guildId))
        return guildId;
    Guild guild = getJDA().getGuildById(guildId);
    if (guild == null) {
        EventCache.LOG.debug("Caching INVITE_DELETE for unknown guild {}", guildId);
        getJDA().getEventCache().cache(EventCache.Type.GUILD, guildId, responseNumber, allContent, this::handle);
        return null;
    }
    long channelId = content.getUnsignedLong("channel_id");
    GuildChannel channel = guild.getGuildChannelById(channelId);
    if (channel == null) {
        EventCache.LOG.debug("Caching INVITE_DELETE for unknown channel {} in guild {}", channelId, guildId);
        getJDA().getEventCache().cache(EventCache.Type.CHANNEL, channelId, responseNumber, allContent, this::handle);
        return null;
    }
    String code = content.getString("code");
    getJDA().handleEvent(new GuildInviteDeleteEvent(getJDA(), responseNumber, code, channel));
    return null;
}
Also used : GuildChannel(net.dv8tion.jda.api.entities.GuildChannel) GuildInviteDeleteEvent(net.dv8tion.jda.api.events.guild.invite.GuildInviteDeleteEvent) Guild(net.dv8tion.jda.api.entities.Guild)

Aggregations

Guild (net.dv8tion.jda.api.entities.Guild)1 GuildChannel (net.dv8tion.jda.api.entities.GuildChannel)1 GuildInviteDeleteEvent (net.dv8tion.jda.api.events.guild.invite.GuildInviteDeleteEvent)1