Package tv.phantombot.discord
Class DiscordAPI
java.lang.Object
tv.phantombot.discord.util.DiscordUtil
tv.phantombot.discord.DiscordAPI
Communicates with the Discord API.
- Author:
- IllusionaryOne, ScaniaTV
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum list of our connection states.final classExtra options for the Discord gatewayNested classes/interfaces inherited from class tv.phantombot.discord.util.DiscordUtil
DiscordUtil.MessageCreateFile -
Method Summary
Modifier and TypeMethodDescriptionvoidMethod that checks if we are still connected to Discord and reconnects if we are not.voidconnect()Connect to Discord with the current token set in the buildervoidMethod to connect to Discord.static DiscordClientMethod that will return the current clientGet the current connection state with Discordstatic GatewayDiscordClientMethod that will return the current gatewaystatic GuildgetGuild()Method that will return the current guild.static SnowflakeMethod that will return the current guild ID If the guild ID is not yet available, it will wait up toGUILDIDTIMEOUTseconds for the guild ID to be set.Method that will return the current guild ID asynchronouslystatic DiscordAPIinstance()Method to return this class object.booleanMethod that checks if we are logged in to Discord.booleanisReady()Method that checks if Discord is ready and has sent all Guilds.voidMethod to reconnect to Discord.Updates the Discord guild IDMethods inherited from class tv.phantombot.discord.util.DiscordUtil
addReaction, addReaction, addReactions, addReactions, addRole, addRole, addRole, bulkDelete, bulkDelete, bulkDeleteMessages, bulkDeleteMessages, canChannelPublish, canChannelPublish, channelId, channelIdAsString, channelName, createRole, deleteMessage, deleteRole, deleteRole, editMessageContent, editMessageEmbed, editUserRoles, editUserRoles, getAllChannelInfo, getAllChannelInfoAsync, getChannel, getChannelAsync, getChannelAsync, getChannelByID, getChannelByIDAsync, getColor, getGuildRoles, getGuildRolesAsync, getLastMessage, getMessageById, getMessagesBefore, getRole, getRoleAsync, getRoleByID, getRoleByIDAsync, getRoleObjects, getRoleObjectsAsync, getRolesAsync, getUser, getUserAsync, getUserById, getUserByIdAsync, getUserRoles, getUserRoles, getUserRolesAsync, getUserRolesAsync, getUsers, getUsersAsync, getUserWithDiscriminator, getUserWithDiscriminatorAsync, isAdministrator, isAdministrator, isAdministratorAsync, isAdministratorAsync, isValidFilePath, removeGame, removeRole, removeRole, resetPresence, sanitizeChannelName, sendFile, sendFile, sendFile, sendFile, sendFileAsync, sendFileAsync, sendFileAsync, sendMessage, sendMessage, sendMessageAsync, sendMessageAsync, sendMessageEmbed, sendMessageEmbed, sendMessageEmbed, sendMessageEmbed, sendMessageEmbedAsync, sendMessageEmbedAsync, sendMessageEmbedAsync, sendPrivateMessage, sendPrivateMessage, sendPrivateMessage, sendPrivateMessageAsync, sendPrivateMessageAsync, sendPrivateMessageAsync, setCompeting, setGame, setListening, setPlaying, setStream, setStreaming, setWatching
-
Method Details
-
instance
Method to return this class object.- Returns:
- the active DiscordAPI instance
-
connect
Method to connect to Discord.- Parameters:
token- API token to connect with
-
connect
public void connect()Connect to Discord with the current token set in the builder -
reconnect
public void reconnect()Method to reconnect to Discord. -
isLoggedIn
public boolean isLoggedIn()Method that checks if we are logged in to Discord.- Returns:
-
isReady
public boolean isReady()Method that checks if Discord is ready and has sent all Guilds.- Returns:
-
getConnectionState
Get the current connection state with Discord- Returns:
- Current connection state
-
checkConnectionStatus
public void checkConnectionStatus()Method that checks if we are still connected to Discord and reconnects if we are not. -
getGuild
Method that will return the current guild.- Returns:
-
updateGuildId
Updates the Discord guild IDThe depends on the
discord_guildidconfiguration:- If set to a specific ID (
> 0), that guild is selected - If set to
0, all detected guild IDs are printed and the first available guild is used - If unset or negative, the first available guild is used
- If set to a specific ID (
-
getGuildIdAsync
Method that will return the current guild ID asynchronously- Returns:
- The current guild IDs Mono
-
getGuildId
Method that will return the current guild ID If the guild ID is not yet available, it will wait up toGUILDIDTIMEOUTseconds for the guild ID to be set. If the guild ID is still not available after the timeout, 0 is returned- Returns:
- The current guild ID, or 0 if not available after the timeout
-
getClient
Method that will return the current client- Returns:
- Discord client instance
-
getGateway
Method that will return the current gateway- Returns:
- Discord gateway instance
-