Search in sources :

Example 1 with Channel

use of net.dv8tion.jda.api.entities.Channel 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 Channel

use of net.dv8tion.jda.api.entities.Channel in project dDiscordBot by DenizenScript.

the class DiscordConnection method getChannel.

public Channel getChannel(long id) {
    Channel result = client.getGuildChannelById(id);
    if (result != null) {
        return result;
    }
    result = client.getPrivateChannelById(id);
    if (result != null) {
        return result;
    }
    return null;
}
Also used : MessageChannel(net.dv8tion.jda.api.entities.MessageChannel) Channel(net.dv8tion.jda.api.entities.Channel)

Example 3 with Channel

use of net.dv8tion.jda.api.entities.Channel in project dDiscordBot by DenizenScript.

the class DiscordConnection method getMessage.

public Message getMessage(long channel, long message) {
    Message result = cache.getMessage(channel, message);
    if (result != null) {
        return result;
    }
    if (!DenizenDiscordBot.allowMessageRetrieval) {
        return null;
    }
    Channel chan = getChannel(channel);
    if (!(chan instanceof MessageChannel)) {
        return null;
    }
    return ((MessageChannel) chan).retrieveMessageById(message).complete();
}
Also used : Message(net.dv8tion.jda.api.entities.Message) MessageChannel(net.dv8tion.jda.api.entities.MessageChannel) MessageChannel(net.dv8tion.jda.api.entities.MessageChannel) Channel(net.dv8tion.jda.api.entities.Channel)

Aggregations

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