Class DiscordAPI


public class DiscordAPI extends DiscordUtil
Communicates with the Discord API.
Author:
IllusionaryOne, ScaniaTV
  • Method Details

    • instance

      public static DiscordAPI instance()
      Method to return this class object.
      Returns:
      the active DiscordAPI instance
    • connect

      public void connect(String token)
      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

      public DiscordAPI.ConnectionState 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

      public static Guild getGuild()
      Method that will return the current guild.
      Returns:
    • updateGuildId

      public static Mono<Void> updateGuildId()
      Updates the Discord guild ID

      The depends on the discord_guildid configuration:

      • 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
    • getGuildIdAsync

      public static Mono<Snowflake> getGuildIdAsync()
      Method that will return the current guild ID asynchronously
      Returns:
      The current guild IDs Mono
    • getGuildId

      public static Snowflake getGuildId()
      Method that will return the current guild ID If the guild ID is not yet available, it will wait up to GUILDIDTIMEOUT seconds 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

      public static DiscordClient getClient()
      Method that will return the current client
      Returns:
      Discord client instance
    • getGateway

      public static GatewayDiscordClient getGateway()
      Method that will return the current gateway
      Returns:
      Discord gateway instance