Package discord4j.rest
Class RestClient
- java.lang.Object
-
- discord4j.rest.RestClient
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RestClient(RestResources restResources)
Create a newRestClient
using the givenRouter
as connector to perform requests.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RestClient
create(String token)
Create aRestClient
with default options, using the given token for authentication.Mono<discord4j.discordjson.json.GuildUpdateData>
createGuild(discord4j.discordjson.json.GuildCreateRequest request)
Requests to create a guild.Mono<discord4j.discordjson.json.UserData>
edit(discord4j.discordjson.json.UserModifyRequest request)
Requests to edit this client (i.e., modify the current bot user).Mono<Long>
getApplicationId()
Mono<discord4j.discordjson.json.ApplicationInfoData>
getApplicationInfo()
Requests to retrieve the application info.ApplicationService
getApplicationService()
Access a low-level representation of the API endpoints for the Application resource.AuditLogService
getAuditLogService()
Access a low-level representation of the API endpoints for the Audit Log resource.RestChannel
getChannelById(Snowflake channelId)
Requests to retrieve the channel represented by the supplied ID.ChannelService
getChannelService()
Access a low-level representation of the API endpoints for the Channel resource.EmojiService
getEmojiService()
Access a low-level representation of the API endpoints for the Guild Emoji resource.GatewayService
getGatewayService()
Access a low-level representation of the API endpoints for the Gateway resource.RestGuild
getGuildById(Snowflake guildId)
Requests to retrieve the guild represented by the supplied ID.RestEmoji
getGuildEmojiById(Snowflake guildId, Snowflake emojiId)
Requests to retrieve the guild emoji represented by the supplied IDs.Flux<discord4j.discordjson.json.UserGuildData>
getGuilds()
Requests to retrieve the guilds the current client is in.GuildService
getGuildService()
Access a low-level representation of the API endpoints for the Guild resource.InteractionService
getInteractionService()
Access a low-level representation of the API endpoints for the Interaction resource.Mono<discord4j.discordjson.json.InviteData>
getInvite(String inviteCode)
Requests to retrieve an invite.InviteService
getInviteService()
Access a low-level representation of the API endpoints for the Invite resource.RestMember
getMemberById(Snowflake guildId, Snowflake userId)
Requests to retrieve the member represented by the supplied IDs.RestMessage
getMessageById(Snowflake channelId, Snowflake messageId)
Requests to retrieve the message represented by the supplied IDs.Flux<discord4j.discordjson.json.RegionData>
getRegions()
Requests to retrieve the voice regions that are available.RestResources
getRestResources()
Obtain theRestResources
associated with thisRestClient
.RestRole
getRoleById(Snowflake guildId, Snowflake roleId)
Requests to retrieve the role represented by the supplied IDs.Mono<discord4j.discordjson.json.UserData>
getSelf()
Requests to retrieve the bot user.Mono<discord4j.discordjson.json.MemberData>
getSelfMember(Snowflake guildId)
Requests to retrieve the bot user, represented as a member of the guild of the supplied IDMono<discord4j.discordjson.json.TemplateData>
getTemplate(String templateCode)
Requests to retrieve an template.TemplateService
getTemplateService()
Access a low-level representation of the API endpoints for the Template resource.RestUser
getUserById(Snowflake userId)
Requests to retrieve the user represented by the supplied ID.UserService
getUserService()
Access a low-level representation of the API endpoints for the User resource.VoiceService
getVoiceService()
Access a low-level representation of the API endpoints for the Voice Region resource.RestWebhook
getWebhookById(Snowflake webhookId)
Requests to retrieve the webhook represented by the supplied ID.WebhookService
getWebhookService()
Access a low-level representation of the API endpoints for the Webhook resource.static RestClientBuilder<RestClient,RouterOptions>
restBuilder(String token)
Obtain aRestClientBuilder
able to createRestClient
instances, using the given token for authentication.RestChannel
restChannel(discord4j.discordjson.json.ChannelData data)
Requests to retrieve the channel represented by the suppliedChannelData
.RestGuild
restGuild(discord4j.discordjson.json.GuildData data)
Requests to retrieve the guild represented by the suppliedGuildData
.RestEmoji
restGuildEmoji(Snowflake guildId, discord4j.discordjson.json.EmojiData data)
Requests to retrieve the guild emoji represented by the supplied ID andEmojiData
.RestMember
restMember(Snowflake guildId, discord4j.discordjson.json.MemberData data)
Requests to retrieve the member represented by the supplied ID andMemberData
RestMessage
restMessage(discord4j.discordjson.json.MessageData data)
Requests to retrieve the message represented by the suppliedMessageData
.RestRole
restRole(Snowflake guildId, discord4j.discordjson.json.RoleData data)
Requests to retrieve the role represented by the supplied ID andRoleData
.RestUser
restUser(discord4j.discordjson.json.UserData data)
Requests to retrieve the user represented by the suppliedUserData
.RestWebhook
restWebhook(discord4j.discordjson.json.WebhookData data)
Requests to retrieve the webhook represented by the suppliedWebhookData
.RestMember
selfRestMember(Snowflake guildId)
Requests to retrieve the bot member from the guild of the supplied ID
-
-
-
Constructor Detail
-
RestClient
protected RestClient(RestResources restResources)
Create a newRestClient
using the givenRouter
as connector to perform requests.- Parameters:
restResources
- a set of REST API resources required to operate this client
-
-
Method Detail
-
create
public static RestClient create(String token)
Create aRestClient
with default options, using the given token for authentication.- Parameters:
token
- the bot token used for authentication- Returns:
- a
RestClient
configured with the default options
-
restBuilder
public static RestClientBuilder<RestClient,RouterOptions> restBuilder(String token)
Obtain aRestClientBuilder
able to createRestClient
instances, using the given token for authentication.- Parameters:
token
- the bot token used for authentication- Returns:
- a
RestClientBuilder
-
getRestResources
public RestResources getRestResources()
Obtain theRestResources
associated with thisRestClient
.- Returns:
- the current
RestResources
for this client
-
getChannelById
public RestChannel getChannelById(Snowflake channelId)
Requests to retrieve the channel represented by the supplied ID.- Parameters:
channelId
- The ID of the channel.- Returns:
- A
RestChannel
as represented by the supplied ID.
-
restChannel
public RestChannel restChannel(discord4j.discordjson.json.ChannelData data)
Requests to retrieve the channel represented by the suppliedChannelData
.- Parameters:
data
- The data of the channel.- Returns:
- A
RestChannel
as represented by the supplied data.
-
getGuildById
public RestGuild getGuildById(Snowflake guildId)
Requests to retrieve the guild represented by the supplied ID.- Parameters:
guildId
- The ID of the guild.- Returns:
- A
RestGuild
as represented by the supplied ID.
-
restGuild
public RestGuild restGuild(discord4j.discordjson.json.GuildData data)
Requests to retrieve the guild represented by the suppliedGuildData
.- Parameters:
data
- The data of the guild.- Returns:
- A
RestGuild
as represented by the supplied data.
-
getGuildEmojiById
public RestEmoji getGuildEmojiById(Snowflake guildId, Snowflake emojiId)
Requests to retrieve the guild emoji represented by the supplied IDs.- Parameters:
guildId
- The ID of the guild.emojiId
- The ID of the emoji.- Returns:
- A
RestEmoji
as represented by the supplied IDs.
-
restGuildEmoji
public RestEmoji restGuildEmoji(Snowflake guildId, discord4j.discordjson.json.EmojiData data)
Requests to retrieve the guild emoji represented by the supplied ID andEmojiData
.- Parameters:
guildId
- The ID of the guild.data
- The data of the emoji.- Returns:
- A
RestEmoji
as represented by the supplied parameters.
-
getMemberById
public RestMember getMemberById(Snowflake guildId, Snowflake userId)
Requests to retrieve the member represented by the supplied IDs.- Parameters:
guildId
- The ID of the guild.userId
- The ID of the user.- Returns:
- A
RestMember
as represented by the supplied IDs.
-
restMember
public RestMember restMember(Snowflake guildId, discord4j.discordjson.json.MemberData data)
Requests to retrieve the member represented by the supplied ID andMemberData
- Parameters:
guildId
- The ID of the guild.data
- The data of the user.- Returns:
- A
RestMember
as represented by the supplied parameters.
-
selfRestMember
public RestMember selfRestMember(Snowflake guildId)
Requests to retrieve the bot member from the guild of the supplied ID- Parameters:
guildId
- the ID of the guild.- Returns:
- A
RestMember
of the bot user as represented by the supplied ID.
-
getMessageById
public RestMessage getMessageById(Snowflake channelId, Snowflake messageId)
Requests to retrieve the message represented by the supplied IDs.- Parameters:
channelId
- The ID of the channel.messageId
- The ID of the message.- Returns:
- A
RestMessage
as represented by the supplied IDs.
-
restMessage
public RestMessage restMessage(discord4j.discordjson.json.MessageData data)
Requests to retrieve the message represented by the suppliedMessageData
.- Parameters:
data
- The data of the channel.- Returns:
- A
RestMessage
as represented by the supplied data.
-
getRoleById
public RestRole getRoleById(Snowflake guildId, Snowflake roleId)
Requests to retrieve the role represented by the supplied IDs.- Parameters:
guildId
- The ID of the guild.roleId
- The ID of the role.- Returns:
- A
RestRole
as represented by the supplied IDs.
-
restRole
public RestRole restRole(Snowflake guildId, discord4j.discordjson.json.RoleData data)
Requests to retrieve the role represented by the supplied ID andRoleData
.- Parameters:
guildId
- The ID of the guild.data
- The data of the role.- Returns:
- A
RestRole
as represented by the supplied parameters.
-
getUserById
public RestUser getUserById(Snowflake userId)
Requests to retrieve the user represented by the supplied ID.- Parameters:
userId
- The ID of the user.- Returns:
- A
RestUser
as represented by the supplied ID.
-
restUser
public RestUser restUser(discord4j.discordjson.json.UserData data)
Requests to retrieve the user represented by the suppliedUserData
.- Parameters:
data
- The data of the user.- Returns:
- A
RestUser
as represented by the supplied data.
-
getWebhookById
public RestWebhook getWebhookById(Snowflake webhookId)
Requests to retrieve the webhook represented by the supplied ID.- Parameters:
webhookId
- The ID of the webhook.- Returns:
- A
RestWebhook
as represented by the supplied ID.
-
restWebhook
public RestWebhook restWebhook(discord4j.discordjson.json.WebhookData data)
Requests to retrieve the webhook represented by the suppliedWebhookData
.- Parameters:
data
- The data of the webhook.- Returns:
- A
RestWebhook
as represented by the supplied ID.
-
getApplicationInfo
public Mono<discord4j.discordjson.json.ApplicationInfoData> getApplicationInfo()
Requests to retrieve the application info.- Returns:
- A
Mono
where, upon successful completion, emits theApplicationInfoData
. If an error is received, it is emitted through theMono
.
-
getGuilds
public Flux<discord4j.discordjson.json.UserGuildData> getGuilds()
Requests to retrieve the guilds the current client is in.- Returns:
- A
Flux
that continually emits theguilds
that the current client is in. If an error is received, it is emitted through theFlux
.
-
getRegions
public Flux<discord4j.discordjson.json.RegionData> getRegions()
Requests to retrieve the voice regions that are available.- Returns:
- A
Flux
that continually emits theregions
that are available. If an error is received, it is emitted through theFlux
.
-
getSelf
public Mono<discord4j.discordjson.json.UserData> getSelf()
Requests to retrieve the bot user.- Returns:
- A
Mono
where, upon successful completion, emits the botuser
. If an error is received, it is emitted through theMono
.
-
getSelfMember
public Mono<discord4j.discordjson.json.MemberData> getSelfMember(Snowflake guildId)
Requests to retrieve the bot user, represented as a member of the guild of the supplied ID- Parameters:
guildId
- The ID of the guild- Returns:
- a
Mono
where, upon successful completion, emits the botmember
. If an error is received, it is emitted through theMono
.
-
createGuild
public Mono<discord4j.discordjson.json.GuildUpdateData> createGuild(discord4j.discordjson.json.GuildCreateRequest request)
Requests to create a guild.- Parameters:
request
- AGuildCreateRequest
as request body.- Returns:
- A
Mono
where, upon successful completion, emits the createdGuildUpdateData
. If an error is received, it is emitted through theMono
.
-
getInvite
public Mono<discord4j.discordjson.json.InviteData> getInvite(String inviteCode)
Requests to retrieve an invite.- Parameters:
inviteCode
- The code for the invite (e.g. "xdYkpp").- Returns:
- A
Mono
where, upon successful completion, emits theInviteData
as represented by the supplied invite code. If an error is received, it is emitted through theMono
.
-
getTemplate
public Mono<discord4j.discordjson.json.TemplateData> getTemplate(String templateCode)
Requests to retrieve an template.- Parameters:
templateCode
- The code for the template (e.g. "hgM48av5Q69A").- Returns:
- A
Mono
where, upon successful completion, emits theTemplateData
as represented by the supplied template code. If an error is received, it is emitted through theMono
.
-
edit
public Mono<discord4j.discordjson.json.UserData> edit(discord4j.discordjson.json.UserModifyRequest request)
Requests to edit this client (i.e., modify the current bot user).- Parameters:
request
- AUserModifyRequest
as request body.- Returns:
- A
Mono
where, upon successful completion, emits the editedUserData
. If an error is received, it is emitted through theMono
.
-
getApplicationService
public ApplicationService getApplicationService()
Access a low-level representation of the API endpoints for the Application resource.- Returns:
- a handle to perform low-level requests to the API
-
getAuditLogService
public AuditLogService getAuditLogService()
Access a low-level representation of the API endpoints for the Audit Log resource.- Returns:
- a handle to perform low-level requests to the API
-
getChannelService
public ChannelService getChannelService()
Access a low-level representation of the API endpoints for the Channel resource. It is recommended you use methods likegetChannelById(Snowflake)
,restChannel(ChannelData)
orRestChannel.create(RestClient, Snowflake)
.- Returns:
- a handle to perform low-level requests to the API
-
getEmojiService
public EmojiService getEmojiService()
Access a low-level representation of the API endpoints for the Guild Emoji resource. It is recommended you use methods likegetGuildEmojiById(Snowflake, Snowflake)
,restGuildEmoji(Snowflake, EmojiData)
orRestEmoji.create(RestClient, Snowflake, Snowflake)
.- Returns:
- a handle to perform low-level requests to the API
-
getGatewayService
public GatewayService getGatewayService()
Access a low-level representation of the API endpoints for the Gateway resource.- Returns:
- a handle to perform low-level requests to the API
-
getGuildService
public GuildService getGuildService()
Access a low-level representation of the API endpoints for the Guild resource. It is recommended you use methods likegetGuildById(Snowflake)
,restGuild(GuildData)
orRestGuild.create(RestClient, Snowflake)
.- Returns:
- a handle to perform low-level requests to the API
-
getInteractionService
public InteractionService getInteractionService()
Access a low-level representation of the API endpoints for the Interaction resource.- Returns:
- a handle to perform low-level requests to the API
-
getInviteService
public InviteService getInviteService()
Access a low-level representation of the API endpoints for the Invite resource. It is recommended you use methods likegetInvite(String)
, orRestInvite.create(RestClient, String)
.- Returns:
- a handle to perform low-level requests to the API
-
getTemplateService
public TemplateService getTemplateService()
Access a low-level representation of the API endpoints for the Template resource. It is recommended you use methods likegetTemplate(String)
, orRestGuildTemplate.create(RestClient, String)
.- Returns:
- a handle to perform low-level requests to the API
-
getUserService
public UserService getUserService()
Access a low-level representation of the API endpoints for the User resource. It is recommended you use methods likegetUserById(Snowflake)
,restUser(UserData)
orRestUser.create(RestClient, Snowflake)
.- Returns:
- a handle to perform low-level requests to the API
-
getVoiceService
public VoiceService getVoiceService()
Access a low-level representation of the API endpoints for the Voice Region resource.- Returns:
- a handle to perform low-level requests to the API
-
getWebhookService
public WebhookService getWebhookService()
Access a low-level representation of the API endpoints for the Webhook resource. It is recommended you use methods likegetWebhookById(Snowflake)
,restWebhook(WebhookData)
orRestWebhook.create(RestClient, Snowflake)
.- Returns:
- a handle to perform low-level requests to the API
-
-