Package discord4j.rest
Class RestClient
java.lang.Object
discord4j.rest.RestClient
An aggregation of all Discord REST API resources available. Each REST resource uses its own class and uses a
common
Router to execute requests.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRestClient(RestResources restResources) Create a newRestClientusing the givenRouteras connector to perform requests. -
Method Summary
Modifier and TypeMethodDescriptionstatic RestClientCreate aRestClientwith 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<discord4j.discordjson.json.ApplicationInfoData>Requests to retrieve the application info.Access a low-level representation of the API endpoints for the Application resource.Access a low-level representation of the API endpoints for the Audit Log resource.Access a low-level representation of the API endpoints for the AutoMod resource.getChannelById(Snowflake channelId) Requests to retrieve the channel represented by the supplied ID.Access a low-level representation of the API endpoints for the Channel resource.Access a low-level representation of the API endpoints for the Guild Emoji resource.Access a low-level representation of the API endpoints for the Gateway resource.getGuildById(Snowflake guildId) Requests to retrieve the guild represented by the supplied ID.getGuildEmojiById(Snowflake guildId, Snowflake emojiId) Requests to retrieve the guild emoji represented by the supplied IDs.Flux<discord4j.discordjson.json.UserGuildData>Requests to retrieve the guilds the current client is in.Access a low-level representation of the API endpoints for the Guild resource.getGuildStickerById(Snowflake guildId, Snowflake stickerId) Requests to retrieve the guild sticker represented by the supplied IDs.Access a low-level representation of the API endpoints for the Interaction resource.Mono<discord4j.discordjson.json.InviteData>Requests to retrieve an invite.Mono<discord4j.discordjson.json.InviteData>getInvite(String inviteCode, boolean withCounts, boolean withExpiration, Snowflake guildScheduledEventId) Requests to retrieve an invite.Access a low-level representation of the API endpoints for the Invite resource.getMemberById(Snowflake guildId, Snowflake userId) Requests to retrieve the member represented by the supplied IDs.getMessageById(Snowflake channelId, Snowflake messageId) Requests to retrieve the message represented by the supplied IDs.Access a low-level representation of the API endpoints for the Monetization resource.Flux<discord4j.discordjson.json.RegionData>Requests to retrieve the voice regions that are available.Obtain theRestResourcesassociated with thisRestClient.getRoleById(Snowflake guildId, Snowflake roleId) Requests to retrieve the role represented by the supplied IDs.getScheduledEventById(Snowflake guildId, Snowflake eventId) Requests to retrieve the scheduled event represented by the supplied ID.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.StageInstanceData>getStageInstance(Snowflake channelId) Requests to retrieve a stage instance.Access a low-level representation of the API endpoints for the Stage Instance resource.Access a low-level representation of the API endpoints for the Guild Sticker resource.Mono<discord4j.discordjson.json.TemplateData>getTemplate(String templateCode) Requests to retrieve an template.Access a low-level representation of the API endpoints for the Template resource.getUserById(Snowflake userId) Requests to retrieve the user represented by the supplied ID.Access a low-level representation of the API endpoints for the User resource.Access a low-level representation of the API endpoints for the Voice Region resource.getWebhookById(Snowflake webhookId) Requests to retrieve the webhook represented by the supplied ID.Access a low-level representation of the API endpoints for the Webhook resource.static RestClientBuilder<RestClient,RouterOptions> restBuilder(String token) Obtain aRestClientBuilderable to createRestClientinstances, using the given token for authentication.restChannel(discord4j.discordjson.json.ChannelData data) Requests to retrieve the channel represented by the suppliedChannelData.restGuild(discord4j.discordjson.json.GuildData data) Requests to retrieve the guild represented by the suppliedGuildData.restGuildEmoji(Snowflake guildId, discord4j.discordjson.json.EmojiData data) Requests to retrieve the guild emoji represented by the supplied ID andEmojiData.restGuildSticker(Snowflake guildId, discord4j.discordjson.json.StickerData data) Requests to retrieve the guild sticker represented by the supplied ID andStickerData.restMember(Snowflake guildId, discord4j.discordjson.json.MemberData data) Requests to retrieve the member represented by the supplied ID andMemberDatarestMessage(discord4j.discordjson.json.MessageData data) Requests to retrieve the message represented by the suppliedMessageData.Requests to retrieve the role represented by the supplied ID andRoleData.restScheduledEvent(Snowflake guildId, discord4j.discordjson.json.GuildScheduledEventData data) restUser(discord4j.discordjson.json.UserData data) Requests to retrieve the user represented by the suppliedUserData.restWebhook(discord4j.discordjson.json.WebhookData data) Requests to retrieve the webhook represented by the suppliedWebhookData.selfRestMember(Snowflake guildId) Requests to retrieve the bot member from the guild of the supplied ID
-
Constructor Details
-
RestClient
Create a newRestClientusing the givenRouteras connector to perform requests.- Parameters:
restResources- a set of REST API resources required to operate this client
-
-
Method Details
-
create
Create aRestClientwith default options, using the given token for authentication.- Parameters:
token- the bot token used for authentication- Returns:
- a
RestClientconfigured with the default options
-
restBuilder
Obtain aRestClientBuilderable to createRestClientinstances, using the given token for authentication.- Parameters:
token- the bot token used for authentication- Returns:
- a
RestClientBuilder
-
getRestResources
Obtain theRestResourcesassociated with thisRestClient.- Returns:
- the current
RestResourcesfor this client
-
getChannelById
Requests to retrieve the channel represented by the supplied ID.- Parameters:
channelId- The ID of the channel.- Returns:
- A
RestChannelas represented by the supplied ID.
-
restChannel
Requests to retrieve the channel represented by the suppliedChannelData.- Parameters:
data- The data of the channel.- Returns:
- A
RestChannelas represented by the supplied data.
-
getGuildById
Requests to retrieve the guild represented by the supplied ID.- Parameters:
guildId- The ID of the guild.- Returns:
- A
RestGuildas represented by the supplied ID.
-
restGuild
Requests to retrieve the guild represented by the suppliedGuildData.- Parameters:
data- The data of the guild.- Returns:
- A
RestGuildas represented by the supplied data.
-
getGuildEmojiById
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
RestEmojias represented by the supplied IDs.
-
restGuildEmoji
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
RestEmojias represented by the supplied parameters.
-
getGuildStickerById
Requests to retrieve the guild sticker represented by the supplied IDs.- Parameters:
guildId- The ID of the guild.stickerId- The ID of the sticker.- Returns:
- A
RestStickeras represented by the supplied IDs.
-
restGuildSticker
Requests to retrieve the guild sticker represented by the supplied ID andStickerData.- Parameters:
guildId- The ID of the guild.data- The data of the sticker.- Returns:
- A
RestStickeras represented by the supplied parameters.
-
getMemberById
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
RestMemberas represented by the supplied IDs.
-
restMember
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
RestMemberas represented by the supplied parameters.
-
selfRestMember
Requests to retrieve the bot member from the guild of the supplied ID- Parameters:
guildId- the ID of the guild.- Returns:
- A
RestMemberof the bot user as represented by the supplied ID.
-
getMessageById
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
RestMessageas represented by the supplied IDs.
-
restMessage
Requests to retrieve the message represented by the suppliedMessageData.- Parameters:
data- The data of the channel.- Returns:
- A
RestMessageas represented by the supplied data.
-
getRoleById
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
RestRoleas represented by the supplied IDs.
-
restRole
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
RestRoleas represented by the supplied parameters.
-
getScheduledEventById
Requests to retrieve the scheduled event represented by the supplied ID.- Parameters:
guildId- The ID of the guildeventId- The ID of the event- Returns:
- A
RestScheduledEventas represented by the supplied IDs.
-
restScheduledEvent
public RestScheduledEvent restScheduledEvent(Snowflake guildId, discord4j.discordjson.json.GuildScheduledEventData data) -
getUserById
Requests to retrieve the user represented by the supplied ID.- Parameters:
userId- The ID of the user.- Returns:
- A
RestUseras represented by the supplied ID.
-
restUser
Requests to retrieve the user represented by the suppliedUserData.- Parameters:
data- The data of the user.- Returns:
- A
RestUseras represented by the supplied data.
-
getWebhookById
Requests to retrieve the webhook represented by the supplied ID.- Parameters:
webhookId- The ID of the webhook.- Returns:
- A
RestWebhookas represented by the supplied ID.
-
restWebhook
Requests to retrieve the webhook represented by the suppliedWebhookData.- Parameters:
data- The data of the webhook.- Returns:
- A
RestWebhookas represented by the supplied ID.
-
getApplicationInfo
Requests to retrieve the application info.- Returns:
- A
Monowhere, upon successful completion, emits theApplicationInfoData. If an error is received, it is emitted through theMono.
-
getGuilds
Requests to retrieve the guilds the current client is in.- Returns:
- A
Fluxthat continually emits theguildsthat the current client is in. If an error is received, it is emitted through theFlux.
-
getRegions
Requests to retrieve the voice regions that are available.- Returns:
- A
Fluxthat continually emits theregionsthat are available. If an error is received, it is emitted through theFlux.
-
getSelf
Requests to retrieve the bot user.- Returns:
- A
Monowhere, upon successful completion, emits the botuser. If an error is received, it is emitted through theMono.
-
getSelfMember
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
Monowhere, 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- AGuildCreateRequestas request body.- Returns:
- A
Monowhere, upon successful completion, emits the createdGuildUpdateData. If an error is received, it is emitted through theMono.
-
getInvite
Requests to retrieve an invite.- Parameters:
inviteCode- The code for the invite (e.g. "xdYkpp").- Returns:
- A
Monowhere, upon successful completion, emits theInviteDataas represented by the supplied invite code. If an error is received, it is emitted through theMono.
-
getInvite
public Mono<discord4j.discordjson.json.InviteData> getInvite(String inviteCode, boolean withCounts, boolean withExpiration, @Nullable Snowflake guildScheduledEventId) Requests to retrieve an invite.- Parameters:
inviteCode- The code for the invite (e.g. "xdYkpp").withCounts- whether the invite should contain approximate member countswithExpiration- whether the invite should contain the expiration dateguildScheduledEventId- the guild scheduled event to include with the invite, can benull- Returns:
- A
Monowhere, upon successful completion, emits theInviteDataas represented by the supplied invite code. If an error is received, it is emitted through theMono.
-
getTemplate
Requests to retrieve an template.- Parameters:
templateCode- The code for the template (e.g. "hgM48av5Q69A").- Returns:
- A
Monowhere, upon successful completion, emits theTemplateDataas 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- AUserModifyRequestas request body.- Returns:
- A
Monowhere, upon successful completion, emits the editedUserData. If an error is received, it is emitted through theMono.
-
getStageInstance
Requests to retrieve a stage instance.- Parameters:
channelId- The channel id associated to the stage instance.- Returns:
- A
Monowhere, upon successful completion, emits theStageInstanceDataassociated to the supplied channel ID. If an error is received, it is emitted through theMono.
-
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
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
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
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
-
getStickerService
Access a low-level representation of the API endpoints for the Guild Sticker resource. It is recommended you use methods likegetGuildStickerById(Snowflake, Snowflake),restGuildSticker(Snowflake, StickerData)orRestSticker.create(RestClient, Snowflake, Snowflake).- Returns:
- a handle to perform low-level requests to the API
-
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
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
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
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
-
getStageInstanceService
Access a low-level representation of the API endpoints for the Stage Instance resource. It is recommended you use thegetStageInstance(Snowflake)method.- Returns:
- a handle to perform low-level requests to the API
-
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
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
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
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
-
getAutoModService
Access a low-level representation of the API endpoints for the AutoMod resource.- Returns:
- a handle to perform low-level requests to the API
-
getMonetizationService
Access a low-level representation of the API endpoints for the Monetization resource.- Returns:
- a handle to perform low-level requests to the API
-
getApplicationId
-
getPollService
-
getSoundboardService
-