Search in sources :

Example 1 with StageChannelImpl

use of net.dv8tion.jda.internal.entities.StageChannelImpl in project JDA by DV8FromTheWorld.

the class StageInstanceDeleteHandler method handleInternally.

@Override
protected Long handleInternally(DataObject content) {
    long guildId = content.getUnsignedLong("guild_id", 0L);
    if (getJDA().getGuildSetupController().isLocked(guildId))
        return guildId;
    GuildImpl guild = (GuildImpl) getJDA().getGuildById(guildId);
    if (guild == null) {
        EventCache.LOG.debug("Caching STAGE_INSTANCE_DELETE for uncached guild with id {}", guildId);
        getJDA().getEventCache().cache(EventCache.Type.GUILD, guildId, responseNumber, allContent, this::handle);
        return null;
    }
    long channelId = content.getUnsignedLong("channel_id", 0L);
    StageChannelImpl channel = (StageChannelImpl) guild.getStageChannelById(channelId);
    if (channel == null)
        return null;
    StageInstance instance = channel.getStageInstance();
    channel.setStageInstance(null);
    if (instance != null)
        getJDA().handleEvent(new StageInstanceDeleteEvent(getJDA(), responseNumber, instance));
    return null;
}
Also used : GuildImpl(net.dv8tion.jda.internal.entities.GuildImpl) StageInstanceDeleteEvent(net.dv8tion.jda.api.events.stage.StageInstanceDeleteEvent) StageInstance(net.dv8tion.jda.api.entities.StageInstance) StageChannelImpl(net.dv8tion.jda.internal.entities.StageChannelImpl)

Aggregations

StageInstance (net.dv8tion.jda.api.entities.StageInstance)1 StageInstanceDeleteEvent (net.dv8tion.jda.api.events.stage.StageInstanceDeleteEvent)1 GuildImpl (net.dv8tion.jda.internal.entities.GuildImpl)1 StageChannelImpl (net.dv8tion.jda.internal.entities.StageChannelImpl)1