Package com.rodiconmc.rodicord
Class Bearer
- java.lang.Object
-
- com.rodiconmc.rodicord.Bearer
-
public class Bearer extends java.lang.ObjectA class for manipulating Bearer/User endpoints. For bots, see theBotclass.
-
-
Constructor Summary
Constructors Constructor Description Bearer(BearerToken token)Basic constructor.Bearer(BearerToken token, Application application)Recommended constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ApplicationgetApplication()java.net.http.HttpRequest.BuildergetHttpBuilder()PartialGuild[]getOwnGuilds()Gets an array ofPartialGuildobjects the current agent is a member of.UsergetSelf()Gets the discord user object for the current agent.java.net.http.HttpResponse<java.lang.String>makeRequest(java.net.http.HttpRequest request)voidrefreshIfNecessary()PerformsrefreshToken()if the access token is expiredvoidrefreshToken()Gets a new Access Token using the refresh token exchange
-
-
-
Constructor Detail
-
Bearer
public Bearer(BearerToken token)
Basic constructor. Subsequent actions may fail if token has expired- Parameters:
token- Token to use
-
Bearer
public Bearer(BearerToken token, Application application)
Recommended constructor. Will renew token using the provided application if necessary.- Parameters:
token- Token to useapplication- Application to renew token with. Must have the same credentials as the application that generated the access/refresh tokens in the first place.
-
-
Method Detail
-
getApplication
public Application getApplication()
-
refreshToken
public void refreshToken()
Gets a new Access Token using the refresh token exchange- See Also:
- Discord Refresh Token Exchange
-
refreshIfNecessary
public void refreshIfNecessary()
PerformsrefreshToken()if the access token is expired
-
getSelf
public User getSelf() throws DiscordException
Gets the discord user object for the current agent.- Returns:
- Current
Userobject - Throws:
DiscordException- See Also:
- Discord Get Current User
-
getOwnGuilds
public PartialGuild[] getOwnGuilds() throws DiscordException
Gets an array ofPartialGuildobjects the current agent is a member of.- Returns:
- Array of
PartialGuildwhich the current agent is a part of. - Throws:
DiscordException
-
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
-
-