public final class DiscordClient extends RestClient
Instances can be obtained by using create(String)
or through builder(String)
. A default instance is
capable of performing REST API operations locally and connecting to the Gateway by using login()
,
withGateway(Function)
or gateway()
.
Modifier and Type | Method and Description |
---|---|
static DiscordClientBuilder<DiscordClient,RouterOptions> |
builder(String token)
Obtain a
DiscordClientBuilder able to create DiscordClient instances, using the given token
for authentication. |
static DiscordClient |
create(String token)
Create a
DiscordClient with default options, using the given token for authentication. |
GatewayBootstrap<GatewayOptions> |
gateway()
Start bootstrapping a connection to the real-time Discord Gateway.
|
CoreResources |
getCoreResources()
Obtain the
CoreResources associated with this DiscordClient . |
Mono<GatewayDiscordClient> |
login()
Login the client to the gateway, using the recommended amount of shards, locally coordinated.
|
Mono<Void> |
withGateway(Function<GatewayDiscordClient,Publisher<?>> whileConnectedFunction)
Connect to the Discord Gateway upon subscription to acquire a
GatewayDiscordClient instance and use it
in a declarative way, releasing the object once the derived usage Function completes, and the underlying
shard group disconnects, according to GatewayDiscordClient.onDisconnect() . |
createGuild, edit, getApplicationInfo, getApplicationService, getAuditLogService, getChannelById, getChannelService, getEmojiService, getGatewayService, getGuildById, getGuildEmojiById, getGuilds, getGuildService, getInvite, getInviteService, getMemberById, getMessageById, getRegions, getRoleById, getSelf, getUserById, getUserService, getVoiceService, getWebhookById, getWebhookService, restBuilder, restChannel, restGuild, restGuildEmoji, restMember, restMessage, restRole, restUser, restWebhook
public static DiscordClient create(String token)
DiscordClient
with default options, using the given token for authentication.token
- the bot token used for authenticationDiscordClient
configured with the default optionspublic static DiscordClientBuilder<DiscordClient,RouterOptions> builder(String token)
DiscordClientBuilder
able to create DiscordClient
instances, using the given token
for authentication.token
- the bot token used for authenticationDiscordClientBuilder
public CoreResources getCoreResources()
CoreResources
associated with this DiscordClient
.CoreResources
for this clientpublic Mono<GatewayDiscordClient> login()
GatewayDiscordClient
is capable of managing these shards and providing a single
EventDispatcher
to publish Gateway updates and StoreService
for entity caching.
To further configure the Gateway connections, such as initial presence, sharding and caching options, see
gateway()
.
Note: Starting from v3.1, this method will return a Mono
of a
GatewayDiscordClient
, emitting the result once shards have connected. Therefore, calling
Mono.block()
will now return upon connection instead of disconnection.
public Mono<Void> withGateway(Function<GatewayDiscordClient,Publisher<?>> whileConnectedFunction)
GatewayDiscordClient
instance and use it
in a declarative way, releasing the object once the derived usage Function
completes, and the underlying
shard group disconnects, according to GatewayDiscordClient.onDisconnect()
.
To further configure the bot features, refer to using gateway()
.
Calling this method is useful when you operate on the GatewayDiscordClient
object using reactive API you
can compose within the scope of the given Function
.
whileConnectedFunction
- the Function
to apply the connected
GatewayDiscordClient
and trigger a processing pipeline from it.Mono
completing after all resources have releasedpublic GatewayBootstrap<GatewayOptions> gateway()
GatewayDiscordClient
which groups all connecting shards providing a single
EventDispatcher
to publish Gateway updates and StoreService
for entity caching.
The following are some of the features configured by this builder:
GatewayDiscordClient
instances.