Class Bot


  • public class Bot
    extends java.lang.Object
    A class for manipulating Bot endpoints. For bots, see the Bearer class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String baseUrl  
      com.google.gson.Gson gson  
    • Constructor Summary

      Constructors 
      Constructor Description
      Bot​(BotToken token)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      DmChannel createDm​(@NotNull java.lang.String recipientId)
      Create a new DM channel with a user.
      Channel getChannel​(@NotNull java.lang.String id)
      Get a channel by ID.
      Guild getGuild​(@NotNull java.lang.String id)
      Get a Guild by ID.
      java.net.http.HttpRequest.Builder getHttpBuilder()  
      PartialGuild[] getOwnGuilds()
      Gets an array of PartialGuild objects the current agent is a member of.
      User getSelf()
      Gets the discord user object for the current agent.
      User getUser​(@NotNull java.lang.String id)
      Gets the discord user object for a given user ID.
      java.net.http.HttpResponse<java.lang.String> makeRequest​(java.net.http.HttpRequest request)  
      User modifySelf​(@Nullable java.lang.String username, @Nullable java.lang.String avatarData)
      Modify the bot's user account settings.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • baseUrl

        public static java.lang.String baseUrl
      • gson

        public final com.google.gson.Gson gson
    • Constructor Detail

    • Method Detail

      • getUser

        public User getUser​(@NotNull
                            @NotNull java.lang.String id)
                     throws DiscordException
        Gets the discord user object for a given user ID.
        Parameters:
        id - Snowflake id of the requested user
        Returns:
        User object from given id
        Throws:
        DiscordException
        See Also:
        Discord Get User
      • modifySelf

        public User modifySelf​(@Nullable
                               @Nullable java.lang.String username,
                               @Nullable
                               @Nullable java.lang.String avatarData)
                        throws DiscordException
        Modify the bot's user account settings. Returns a User object on success. All parameters are optional, and can be omitted by providing a null pointer
        Parameters:
        username - New Username
        avatarData - New avatar data
        Returns:
        New User object
        Throws:
        DiscordException
        See Also:
        Discord Modify Current User
      • getChannel

        public Channel getChannel​(@NotNull
                                  @NotNull java.lang.String id)
        Get a channel by ID. Returns a subclass of the Channel object
        Parameters:
        id - Snowflake id of the channel
        Returns:
        A subclass of the Channel object
      • getGuild

        public Guild getGuild​(@NotNull
                              @NotNull java.lang.String id)
        Get a Guild by ID. Returns a Guild object
        Parameters:
        id - Snowflake id of the guild
        Returns:
        A Guild object
      • getHttpBuilder

        public java.net.http.HttpRequest.Builder getHttpBuilder()
      • makeRequest

        public java.net.http.HttpResponse<java.lang.String> makeRequest​(java.net.http.HttpRequest request)
                                                                 throws DiscordException
        Throws:
        DiscordException