Java Discord API - A comprehensive Java library for building Discord bots and applications
—
Comprehensive object model representing all Discord entities including users, guilds, channels, messages, and roles with full CRUD operations and relationship management.
Core user representation and management functionality.
/**
* Represents a Discord User. Contains all publicly available information about a specific Discord User.
*/
interface User extends ISnowflake, IMentionable {
/** Get username */
String getName();
/** Get user discriminator (legacy, mostly #0000 now) */
String getDiscriminator();
/** Get global display name */
String getGlobalName();
/** Get effective name (global name or username) */
String getEffectiveName();
/** Get avatar hash */
String getAvatarId();
/** Get avatar URL with default size */
String getAvatarUrl();
/** Get avatar URL with specific size and format */
String getAvatarUrl(int size);
String getAvatarUrl(ImageProxy.Format format);
String getAvatarUrl(ImageProxy.Format format, int size);
/** Get effective avatar URL (avatar or default) */
String getEffectiveAvatarUrl();
/** Get default avatar URL */
String getDefaultAvatarUrl();
/** Check if this is a bot account */
boolean isBot();
/** Check if this is a system account */
boolean isSystem();
/** Get user flags */
EnumSet<User.UserFlag> getFlags();
/** Open private channel with user */
RestAction<PrivateChannel> openPrivateChannel();
/** Retrieve full profile information */
RestAction<User.Profile> retrieveProfile();
/** Get mutual guilds with this user */
List<Guild> getMutualGuilds();
/** Check if user has animated avatar */
boolean hasAvatar();
}Guild-specific user representation with roles, permissions, and moderation capabilities.
/**
* Represents a Guild-specific User.
* Contains all guild-specific information about a User.
*/
interface Member extends ISnowflake, IMentionable {
/** Get underlying User object */
User getUser();
/** Get JDA instance */
JDA getJDA();
/** Get guild this member belongs to */
Guild getGuild();
/** Get guild-specific nickname */
String getNickname();
/** Get effective name in guild (nickname or user name) */
String getEffectiveName();
/** Get member roles in hierarchy order */
List<Role> getRoles();
/** Get member's color from highest colored role */
Color getColor();
/** Get member's color from highest colored role as RGB int */
int getColorRaw();
/** Get effective permissions in guild */
EnumSet<Permission> getPermissions();
/** Get effective permissions in specific channel */
EnumSet<Permission> getPermissions(GuildChannel channel);
/** Get effective permissions with explicit overrides */
EnumSet<Permission> getPermissionsExplicit();
EnumSet<Permission> getPermissionsExplicit(GuildChannel channel);
/** Check if member has specific permissions */
boolean hasPermission(Permission... permissions);
boolean hasPermission(GuildChannel channel, Permission... permissions);
/** Check if member has specific permissions (collection) */
boolean hasPermission(Collection<Permission> permissions);
boolean hasPermission(GuildChannel channel, Collection<Permission> permissions);
/** Get when member joined guild */
OffsetDateTime getTimeJoined();
/** Get when member started boosting guild */
OffsetDateTime getTimeBoosted();
/** Check if member is guild owner */
boolean isOwner();
/** Check if member is pending membership screening */
boolean isPending();
/** Get member's avatar hash (guild-specific) */
String getAvatarId();
/** Get member's avatar URL (guild-specific) */
String getAvatarUrl();
String getAvatarUrl(int size);
String getEffectiveAvatarUrl();
/** Get member's banner hash */
String getBannerId();
/** Get member's banner URL */
String getBannerUrl();
/** Get voice state if member is in voice channel */
GuildVoiceState getVoiceState();
/** Get current online status */
OnlineStatus getOnlineStatus();
OnlineStatus getOnlineStatus(ClientType type);
/** Get current activities */
List<Activity> getActivities();
/** Kick member from guild */
AuditableRestAction<Void> kick();
AuditableRestAction<Void> kick(String reason);
/** Ban member from guild */
AuditableRestAction<Void> ban(int delDays, TimeUnit unit);
AuditableRestAction<Void> ban(int delDays, TimeUnit unit, String reason);
/** Timeout member (restrict communication) */
AuditableRestAction<Void> timeoutFor(long amount, TimeUnit unit);
AuditableRestAction<Void> timeoutFor(long amount, TimeUnit unit, String reason);
AuditableRestAction<Void> timeoutUntil(TemporalAccessor temporal);
AuditableRestAction<Void> timeoutUntil(TemporalAccessor temporal, String reason);
/** Remove timeout from member */
AuditableRestAction<Void> removeTimeout();
AuditableRestAction<Void> removeTimeout(String reason);
/** Move member to different voice channel */
AuditableRestAction<Void> modifyNickname(String nickname);
AuditableRestAction<Void> modifyNickname(String nickname, String reason);
}Discord server representation with comprehensive management capabilities.
/**
* Represents a Discord Guild (Server).
* This provides all information and functionality related to Discord Guilds.
*/
interface Guild extends ISnowflake, IGuildChannelContainer<GuildChannel> {
/** Get guild name */
String getName();
/** Get guild description */
String getDescription();
/** Get guild icon hash */
String getIconId();
/** Get guild icon URL */
String getIconUrl();
String getIconUrl(int size);
String getIconUrl(ImageProxy.Format format);
/** Get guild features */
Set<String> getFeatures();
/** Get guild splash hash */
String getSplashId();
/** Get guild splash URL */
String getSplashUrl();
String getSplashUrl(int size);
/** Get guild banner hash */
String getBannerId();
/** Get guild banner URL */
String getBannerUrl();
String getBannerUrl(int size);
/** Get guild discovery splash hash */
String getDiscoverySplashId();
/** Get guild discovery splash URL */
String getDiscoverySplashUrl();
/** Get guild owner */
Member getOwner();
long getOwnerIdLong();
String getOwnerId();
/** Get guild region */
String getRegion();
/** Get guild locale */
Locale getLocale();
/** Get verification level */
Guild.VerificationLevel getVerificationLevel();
/** Get default notification level */
Guild.NotificationLevel getDefaultNotificationLevel();
/** Get explicit content filter level */
Guild.ExplicitContentLevel getExplicitContentLevel();
/** Get required MFA level */
Guild.MFALevel getMFALevel();
/** Get boost tier */
Guild.BoostTier getBoostTier();
/** Get boost count */
int getBoostCount();
/** Get boosters */
List<Member> getBoosters();
/** Get max members */
int getMaxMembers();
/** Get max presences */
int getMaxPresences();
/** Get vanity URL code */
String getVanityCode();
/** Get vanity URL */
String getVanityUrl();
/** Get all guild members */
List<Member> getMembers();
/** Get member cache */
SnowflakeCacheView<Member> getMemberCache();
/** Get member by ID */
Member getMemberById(long userId);
Member getMemberById(String userId);
/** Get members by name */
List<Member> getMembersByName(String name, boolean ignoreCase);
/** Get members by nickname */
List<Member> getMembersByNickname(String nickname, boolean ignoreCase);
/** Get members by effective name */
List<Member> getMembersByEffectiveName(String name, boolean ignoreCase);
/** Get members with specific role */
List<Member> getMembersWithRoles(Role... roles);
List<Member> getMembersWithRoles(Collection<Role> roles);
/** Get all guild roles */
List<Role> getRoles();
/** Get role cache */
SnowflakeCacheView<Role> getRoleCache();
/** Get role by ID */
Role getRoleById(long roleId);
Role getRoleById(String roleId);
/** Get roles by name */
List<Role> getRolesByName(String name, boolean ignoreCase);
/** Get public role (@everyone) */
Role getPublicRole();
/** Get all guild channels */
List<GuildChannel> getChannels();
/** Get all text channels */
List<TextChannel> getTextChannels();
/** Get all voice channels */
List<VoiceChannel> getVoiceChannels();
/** Get all stage channels */
List<StageChannel> getStageChannels();
/** Get all forum channels */
List<ForumChannel> getForumChannels();
/** Get all thread channels */
List<ThreadChannel> getThreadChannels();
/** Get all categories */
List<Category> getCategories();
/** Get system channel (default channel for system messages) */
TextChannel getSystemChannel();
/** Get rules channel */
TextChannel getRulesChannel();
/** Get community updates channel */
TextChannel getCommunityUpdatesChannel();
/** Get AFK channel */
VoiceChannel getAfkChannel();
/** Get AFK timeout */
Guild.Timeout getAfkTimeout();
/** Create role */
RoleAction createRole();
/** Create text channel */
ChannelAction<TextChannel> createTextChannel(String name);
ChannelAction<TextChannel> createTextChannel(String name, Category parent);
/** Create voice channel */
ChannelAction<VoiceChannel> createVoiceChannel(String name);
ChannelAction<VoiceChannel> createVoiceChannel(String name, Category parent);
/** Create stage channel */
ChannelAction<StageChannel> createStageChannel(String name);
ChannelAction<StageChannel> createStageChannel(String name, Category parent);
/** Create forum channel */
ChannelAction<ForumChannel> createForumChannel(String name);
ChannelAction<ForumChannel> createForumChannel(String name, Category parent);
/** Create category */
ChannelAction<Category> createCategory(String name);
/** Ban user */
AuditableRestAction<Void> ban(UserSnowflake user, int delDays, TimeUnit unit);
AuditableRestAction<Void> ban(UserSnowflake user, int delDays, TimeUnit unit, String reason);
/** Unban user */
AuditableRestAction<Void> unban(UserSnowflake user);
AuditableRestAction<Void> unban(UserSnowflake user, String reason);
/** Kick member */
AuditableRestAction<Void> kick(UserSnowflake user);
AuditableRestAction<Void> kick(UserSnowflake user, String reason);
/** Retrieve ban list */
RestAction<List<Guild.Ban>> retrieveBans();
/** Retrieve ban by user */
RestAction<Guild.Ban> retrieveBan(UserSnowflake user);
/** Retrieve audit logs */
PaginationAction<AuditLogEntry> retrieveAuditLogs();
/** Retrieve member by ID */
RestAction<Member> retrieveMemberById(long userId);
RestAction<Member> retrieveMemberById(String userId);
/** Retrieve members */
Task<List<Member>> loadMembers();
/** Get guild manager */
GuildManager getManager();
/** Leave guild */
RestAction<Void> leave();
/** Delete guild (owner only) */
RestAction<Void> delete();
/** Get audio manager */
AudioManager getAudioManager();
}Comprehensive channel hierarchy with all Discord channel types and their specific functionalities.
/**
* Base interface for all Discord channels.
*/
interface Channel extends ISnowflake {
/** Get channel name */
String getName();
/** Get channel type */
ChannelType getType();
/** Get JDA instance */
JDA getJDA();
/** Format as mention */
String getAsMention();
}
/**
* Represents a Text Channel in a Guild.
*/
interface TextChannel extends StandardGuildMessageChannel, IMemberContainer,
IThreadContainer, IWebhookContainer {
/** Get channel topic */
String getTopic();
/** Check if channel is NSFW */
boolean isNSFW();
/** Get slowmode delay in seconds */
int getSlowmode();
/** Send message */
MessageCreateAction sendMessage(CharSequence text);
MessageCreateAction sendMessage(MessageEmbed embed);
MessageCreateAction sendMessage(MessageCreateData message);
/** Send message embeds */
MessageCreateAction sendMessageEmbeds(MessageEmbed... embeds);
MessageCreateAction sendMessageEmbeds(Collection<? extends MessageEmbed> embeds);
/** Send files */
MessageCreateAction sendFiles(FileUpload... files);
MessageCreateAction sendFiles(Collection<? extends FileUpload> files);
/** Get message history */
MessageHistory getHistory();
/** Retrieve message by ID */
RestAction<Message> retrieveMessageById(long messageId);
RestAction<Message> retrieveMessageById(String messageId);
/** Retrieve pinned messages */
RestAction<List<Message>> retrievePinnedMessages();
/** Create invite */
InviteAction createInvite();
/** Retrieve invites */
RestAction<List<Invite>> retrieveInvites();
/** Create webhook */
WebhookAction createWebhook(String name);
/** Retrieve webhooks */
RestAction<List<Webhook>> retrieveWebhooks();
/** Create thread from message */
ThreadChannelAction createThreadChannel(String name, long messageId);
/** Create forum post thread */
ForumPostAction createForumPost(String name, MessageCreateData message);
/** Get channel manager */
TextChannelManager getManager();
/** Delete channel */
AuditableRestAction<Void> delete();
}
/**
* Represents a Voice Channel in a Guild.
*/
interface VoiceChannel extends StandardGuildChannel, IAudioChannel {
/** Get user limit (0 = unlimited) */
int getUserLimit();
/** Get bitrate */
int getBitrate();
/** Get RTC region */
String getRegion();
/** Get members currently connected */
List<Member> getMembers();
/** Create invite */
InviteAction createInvite();
/** Get channel manager */
VoiceChannelManager getManager();
}
/**
* Represents a Private Channel (Direct Message).
*/
interface PrivateChannel extends MessageChannel {
/** Get the user this DM is with */
User getUser();
/** Close private channel */
RestAction<Void> close();
}Role representation and management with permissions and hierarchy.
/**
* Represents a Guild's Role.
*/
interface Role extends ISnowflake, IMentionable, IPermissionHolder, Comparable<Role> {
/** Get role name */
String getName();
/** Check if role is managed by integration */
boolean isManaged();
/** Check if role is hoisted (displayed separately) */
boolean isHoisted();
/** Check if role is mentionable by everyone */
boolean isMentionable();
/** Check if role is public role (@everyone) */
boolean isPublicRole();
/** Check if role can interact with other role */
boolean canInteract(Role role);
/** Check if role can interact with member */
boolean canInteract(Member member);
/** Get role color */
Color getColor();
/** Get role color as RGB int */
int getColorRaw();
/** Get role position in hierarchy */
int getPosition();
/** Get role position relative to other roles */
int getPositionRaw();
/** Get role permissions */
EnumSet<Permission> getPermissions();
long getPermissionsRaw();
/** Get role icon hash */
String getIconId();
/** Get role icon URL */
String getIconUrl();
String getIconUrl(int size);
/** Get role emoji */
RoleIcon getIcon();
/** Get role tags */
RoleTag getTags();
/** Get guild this role belongs to */
Guild getGuild();
/** Get role manager */
RoleManager getManager();
/** Delete role */
AuditableRestAction<Void> delete();
AuditableRestAction<Void> delete(String reason);
}// User flags
enum UserFlag {
STAFF, PARTNER, HYPESQUAD, BUG_HUNTER_LEVEL_1, HYPESQUAD_ONLINE_HOUSE_1,
HYPESQUAD_ONLINE_HOUSE_2, HYPESQUAD_ONLINE_HOUSE_3, PREMIUM_EARLY_SUPPORTER,
TEAM_PSEUDO_USER, BUG_HUNTER_LEVEL_2, VERIFIED_BOT, VERIFIED_DEVELOPER,
CERTIFIED_MODERATOR, BOT_HTTP_INTERACTIONS, ACTIVE_DEVELOPER
}
// Guild verification levels
enum VerificationLevel {
NONE, LOW, MEDIUM, HIGH, VERY_HIGH
}
// Guild notification levels
enum NotificationLevel {
ALL_MESSAGES, MENTIONS_ONLY
}
// Guild explicit content filter levels
enum ExplicitContentLevel {
OFF, MEMBERS_WITHOUT_ROLES, ALL_MEMBERS
}
// Guild MFA levels
enum MFALevel {
NONE, ELEVATED
}
// Guild boost tiers
enum BoostTier {
NONE, TIER_1, TIER_2, TIER_3
}
// AFK timeout options
enum Timeout {
SECONDS_60, SECONDS_300, SECONDS_900, SECONDS_1800, SECONDS_3600
}Install with Tessl CLI
npx tessl i tessl/maven-net-dv8tion--jda