Search in sources :

Example 1 with ChannelCreateEvent

use of net.dv8tion.jda.api.events.channel.ChannelCreateEvent in project JDA by DV8FromTheWorld.

the class ChannelCreateHandler method handleInternally.

@Override
protected Long handleInternally(DataObject content) {
    ChannelType type = ChannelType.fromId(content.getInt("type"));
    long guildId = 0;
    JDAImpl jda = getJDA();
    if (type.isGuild()) {
        guildId = content.getLong("guild_id");
        if (jda.getGuildSetupController().isLocked(guildId))
            return guildId;
    }
    Channel channel = buildChannel(type, content, guildId);
    if (channel == null) {
        WebSocketClient.LOG.debug("Discord provided an CREATE_CHANNEL event with an unknown channel type! JSON: {}", content);
        return null;
    }
    jda.handleEvent(new ChannelCreateEvent(jda, responseNumber, channel));
    return null;
}
Also used : ChannelCreateEvent(net.dv8tion.jda.api.events.channel.ChannelCreateEvent) Channel(net.dv8tion.jda.api.entities.Channel) JDAImpl(net.dv8tion.jda.internal.JDAImpl) ChannelType(net.dv8tion.jda.api.entities.ChannelType)

Example 2 with ChannelCreateEvent

use of net.dv8tion.jda.api.events.channel.ChannelCreateEvent in project JDA by DV8FromTheWorld.

the class ThreadCreateHandler method handleInternally.

@Override
protected Long handleInternally(DataObject content) {
    long guildId = content.getLong("guild_id");
    if (api.getGuildSetupController().isLocked(guildId))
        return guildId;
    ThreadChannel thread = api.getEntityBuilder().createThreadChannel(content, guildId);
    api.handleEvent(new ChannelCreateEvent(api, responseNumber, thread));
    return null;
}
Also used : ChannelCreateEvent(net.dv8tion.jda.api.events.channel.ChannelCreateEvent) ThreadChannel(net.dv8tion.jda.api.entities.ThreadChannel)

Aggregations

ChannelCreateEvent (net.dv8tion.jda.api.events.channel.ChannelCreateEvent)2 Channel (net.dv8tion.jda.api.entities.Channel)1 ChannelType (net.dv8tion.jda.api.entities.ChannelType)1 ThreadChannel (net.dv8tion.jda.api.entities.ThreadChannel)1 JDAImpl (net.dv8tion.jda.internal.JDAImpl)1