Skip to main content
Represents Discord channels of various types. This is the abstract interface for all channel types.

Overview

JDA provides various channel types representing different kinds of Discord channels. All channels implement the base Channel interface.

Channel Types

Discord has several channel types, each with specific purposes:

Text Channels

TextChannel - Standard text channels in guilds
  • Send and receive messages
  • Support threads, webhooks, and channel permissions
  • Can be organized in categories
TextChannel textChannel = guild.getTextChannelById(channelId);
textChannel.sendMessage("Hello!").queue();

Voice Channels

VoiceChannel - Voice communication channels in guilds
  • Support voice and video communication
  • Can have user limits and bitrate settings
  • Support stage instances for events
VoiceChannel voiceChannel = guild.getVoiceChannelById(channelId);
int bitrate = voiceChannel.getBitrate();

Private Channels

PrivateChannel - Direct message channels between users
  • One-on-one communication
  • No guild context
user.openPrivateChannel()
    .flatMap(channel -> channel.sendMessage("Hello!"))
    .queue();

Thread Channels

ThreadChannel - Temporary sub-channels for organized discussions
  • Created from messages or as standalone threads
  • Can be public or private
  • Automatically archive after inactivity
ThreadChannel thread = textChannel.createThreadChannel("Discussion", true)
    .queue();

Forum Channels

ForumChannel - Post-based discussion channels
  • Each post is a thread
  • Support tags for organization
  • Can require tags and have post guidelines
ForumChannel forum = guild.getForumChannelById(channelId);
forum.createForumPost("Topic", MessageCreateData.fromContent("Content"))
    .queue();

Category Channels

Category - Organizational containers for other channels
  • Group channels together
  • Apply permissions to all child channels
Category category = guild.getCategoryById(categoryId);
List<GuildChannel> channels = category.getChannels();

Base Channel Properties

Common Methods

getId()
String
The Snowflake id of this channel.
String channelId = channel.getId();
getIdLong()
long
The Snowflake id of this channel as a primitive long.
long channelId = channel.getIdLong();
getName()
String
The human readable name of this channel.
String name = channel.getName();
getType()
ChannelType
The ChannelType for this channel.
ChannelType type = channel.getType();
if (type == ChannelType.TEXT) {
    // Handle text channel
}
getJDA()
JDA
Returns the JDA instance of this channel.
JDA jda = channel.getJDA();
getAsMention()
String
Returns a mention tag for this channel.
String mention = channel.getAsMention(); // Returns: <#channelId>

Guild Channel Properties

For channels in guilds (TextChannel, VoiceChannel, etc.):
getGuild()
Guild
The Guild this channel belongs to.
Guild guild = guildChannel.getGuild();
getPosition()
int
The position of this channel in the channel list.
int position = guildChannel.getPosition();
getParentCategory()
Category
The parent Category of this channel.Returns null if this channel doesn’t have a parent category.
Category parent = guildChannel.getParentCategory();

Message Channel Properties

For channels that support messages (TextChannel, PrivateChannel, ThreadChannel):
sendMessage(CharSequence content)
MessageCreateAction
Sends a message to this channel.
channel.sendMessage("Hello, world!")
    .queue();
sendMessageEmbeds(MessageEmbed... embeds)
MessageCreateAction
Sends embeds to this channel.
EmbedBuilder embed = new EmbedBuilder()
    .setTitle("Title")
    .setDescription("Description");

channel.sendMessageEmbeds(embed.build())
    .queue();
retrieveMessageById(String messageId)
RestAction<Message>
Retrieves a message by its id.
channel.retrieveMessageById(messageId)
    .queue(message -> {
        System.out.println(message.getContentDisplay());
    });
getHistory()
MessageHistory
Gets the MessageHistory for this channel.
MessageHistory history = channel.getHistory();
history.retrievePast(100).queue(messages -> {
    System.out.println("Retrieved " + messages.size() + " messages");
});

Channel Management

Deletion

delete()
RestAction<Void>
Deletes this channel.
channel.delete()
    .reason("No longer needed")
    .queue();

Editing (Guild Channels)

getManager()
ChannelManager
The ChannelManager for this channel. Used to modify channel settings.
textChannel.getManager()
    .setName("new-name")
    .setTopic("New topic")
    .queue();

Usage Examples

Creating Channels

// Create text channel
guild.createTextChannel("general")
    .setTopic("General discussion")
    .setParent(category)
    .queue();

// Create voice channel
guild.createVoiceChannel("Voice Chat")
    .setUserLimit(10)
    .setBitrate(96000)
    .queue();

// Create thread
textChannel.createThreadChannel("Discussion", true)
    .queue(thread -> {
        thread.sendMessage("Welcome to the thread!").queue();
    });

Working with Messages

// Send message
MessageCreateAction action = channel.sendMessage("Hello!");
action.queue();

// Send with embed
EmbedBuilder embed = new EmbedBuilder()
    .setTitle("Announcement")
    .setDescription("Important message");

channel.sendMessageEmbeds(embed.build())
    .queue();

// Retrieve message history
channel.getHistory()
    .retrievePast(50)
    .queue(messages -> {
        for (Message msg : messages) {
            System.out.println(msg.getContentDisplay());
        }
    });

Managing Permissions

// Add permission override
textChannel.upsertPermissionOverride(role)
    .grant(Permission.MESSAGE_SEND)
    .deny(Permission.MESSAGE_MANAGE)
    .queue();

// Remove permission override
textChannel.getPermissionOverride(member)
    .delete()
    .queue();

Modifying Channels

// Modify text channel
textChannel.getManager()
    .setName("updated-name")
    .setTopic("New topic")
    .setSlowmode(5) // 5 second slowmode
    .queue();

// Modify voice channel
voiceChannel.getManager()
    .setUserLimit(20)
    .setBitrate(128000)
    .queue();

// Move channel position
channel.getManager()
    .setPosition(0) // Move to top
    .queue();

Channel Type Constants

The ChannelType enum includes:
  • TEXT - Guild text channel
  • PRIVATE - Private direct message channel
  • VOICE - Guild voice channel
  • CATEGORY - Channel category
  • NEWS - Guild news/announcement channel
  • STAGE - Stage voice channel
  • GUILD_PUBLIC_THREAD - Public thread channel
  • GUILD_PRIVATE_THREAD - Private thread channel
  • FORUM - Forum channel
  • MEDIA - Media channel

Constants

MAX_NAME_LENGTH
int
The maximum length a channel name can be: 100

See Also

Build docs developers (and LLMs) love