Package com.mewna.catnip.internal
Class CatnipImpl
java.lang.Object
com.mewna.catnip.internal.CatnipImpl
- All Implemented Interfaces:
Catnip
,AutoCloseable
- Since:
- 8/31/18.
- Author:
- amy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.bouncycastle.jce.provider.BouncyCastleProvider
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
chunkMembers
(String guildId, String query, int limit, String nonce) Request guild members for the given guild.clientId()
The ID of this clientlong
The ID of this client, as a long.void
closeVoiceConnection
(long guildId) Closes the voice connection on the specified guild.void
closeVoiceConnection
(String guildId) Closes the voice connection on the specified guild.connect()
Start all shards asynchronously.The entity builder used by this catnip instance.io.reactivex.rxjava3.core.Single<GatewayInfo>
Fetches the gateway info and updates the cache.injectOptions
(Extension extension, UnaryOperator<CatnipOptions> optionsPatcher) Inject options into this catnip instance from the given extension.boolean
isUnavailable
(String guildId) latch()
loadExtension
(Extension extension) Load an extension for this catnip instance.boolean
void
markAvailable
(String id) void
void
openVoiceConnection
(String guildId, String channelId, boolean selfMute, boolean selfDeaf) Opens a voice connection to the provided guild and channel.options()
presence
(int shardId) Get the presence for the specified shard.void
Update the presence for all shards.void
presence
(Presence.OnlineStatus status, String game, Presence.ActivityType type, String url) Update the presence for all shards by specifying each part of the presence individually.void
Update the presence for a specific shard.rest()
io.reactivex.rxjava3.core.Maybe<User>
selfUser()
io.reactivex.rxjava3.core.Single<Catnip>
setup()
void
shutdown()
Shutdown the catnip instance, and undeploy all shards.boolean
token()
boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.mewna.catnip.Catnip
cache, cacheWorker, chunkMembers, chunkMembers, chunkMembers, chunkMembers, chunkMembers, chunkMembers, chunkMembers, chunkMembers, chunkMembers, chunkMembers, close, dispatchManager, entitySerializer, eventBuffer, extension, flowable, flowable, game, logAdapter, observable, observable, openVoiceConnection, openVoiceConnection, openVoiceConnection, parseWebhook, parseWebhook, rxScheduler, sessionManager, shardManager, status, taskScheduler, validateSignature
-
Field Details
-
BOUNCY_CASTLE_PROVIDER
public static final org.bouncycastle.jce.provider.BouncyCastleProvider BOUNCY_CASTLE_PROVIDER
-
-
Constructor Details
-
CatnipImpl
-
-
Method Details
-
injectOptions
@Nonnull public Catnip injectOptions(@Nonnull Extension extension, @Nonnull UnaryOperator<CatnipOptions> optionsPatcher) Description copied from interface:Catnip
Inject options into this catnip instance from the given extension. This allows extensions to do things like automatically register a new cache worker without having to tell the end-user to specify options. By default, options that get injected will be logged.- Specified by:
injectOptions
in interfaceCatnip
- Parameters:
extension
- The extension injecting the options.optionsPatcher
- Function responsible for updating the settings.- Returns:
- Itself.
-
requester
-
loadExtension
Description copied from interface:Catnip
Load an extension for this catnip instance. SeeExtension
for more information.- Specified by:
loadExtension
in interfaceCatnip
- Parameters:
extension
- The extension to load.- Returns:
- Itself.
-
selfUser
-
clientId
Description copied from interface:Catnip
The ID of this client -
clientIdAsLong
public long clientIdAsLong()Description copied from interface:Catnip
The ID of this client, as a long.- Specified by:
clientIdAsLong
in interfaceCatnip
- Returns:
- The ID of the client, as a long.
-
shutdown
public void shutdown()Description copied from interface:Catnip
Shutdown the catnip instance, and undeploy all shards. -
markAvailable
-
openVoiceConnection
public void openVoiceConnection(@Nonnull String guildId, @Nonnull String channelId, boolean selfMute, boolean selfDeaf) Description copied from interface:Catnip
Opens a voice connection to the provided guild and channel. The connection is opened asynchronously, withVOICE_STATE_UPDATE
andVOICE_SERVER_UPDATE
events being fired when the connection is opened.- Specified by:
openVoiceConnection
in interfaceCatnip
- Parameters:
guildId
- Guild to connect.channelId
- Channel to connect.selfMute
- Whether or not to connect as muted.selfDeaf
- Whether or not to connect as deafened.
-
closeVoiceConnection
Description copied from interface:Catnip
Closes the voice connection on the specified guild.- Specified by:
closeVoiceConnection
in interfaceCatnip
- Parameters:
guildId
- Guild to disconnect.
-
closeVoiceConnection
public void closeVoiceConnection(long guildId) Description copied from interface:Catnip
Closes the voice connection on the specified guild.- Specified by:
closeVoiceConnection
in interfaceCatnip
- Parameters:
guildId
- Guild to disconnect.
-
chunkMembers
public void chunkMembers(@Nonnull String guildId, @Nonnull String query, @Nonnegative int limit, @Nullable String nonce) Description copied from interface:Catnip
Request guild members for the given guild.- Specified by:
chunkMembers
in interfaceCatnip
- Parameters:
guildId
- Guild to request for.query
- Members returned must have a username starting with this.limit
- Maximum number of members to return. 0 for no limit.nonce
- Nonce to use for knowing which chunks came from which request.
-
presence
Description copied from interface:Catnip
Get the presence for the specified shard. -
presence
Description copied from interface:Catnip
Update the presence for all shards. -
presence
Description copied from interface:Catnip
Update the presence for a specific shard. -
presence
public void presence(@Nullable Presence.OnlineStatus status, @Nullable String game, @Nullable Presence.ActivityType type, @Nullable String url) Description copied from interface:Catnip
Update the presence for all shards by specifying each part of the presence individually.- Specified by:
presence
in interfaceCatnip
- Parameters:
status
- The new online status. Set tonull
for online.game
- The new game name. Set tonull
to clear.type
- The type of the new game status. Set tonull
for "playing."url
- The new URL for the presence. Will be ignored iftype
is notPresence.ActivityType.STREAMING
.
-
setup
-
connect
Description copied from interface:Catnip
Start all shards asynchronously. To customize the shard spawning / management strategy, seeCatnipOptions
. -
gatewayInfo
- Specified by:
gatewayInfo
in interfaceCatnip
- Returns:
- The cached gateway info. May be null if it hasn't been fetched yet.
-
fetchGatewayInfo
Description copied from interface:Catnip
Fetches the gateway info and updates the cache. Calls made toCatnip.gatewayInfo()
after this stage completes successfully are guaranteed to return a non null value.Updates the cached gateway info.
- Specified by:
fetchGatewayInfo
in interfaceCatnip
- Returns:
- The gateway info fetched from discord.
-
token
-
logExtensionOverrides
public boolean logExtensionOverrides() -
validateToken
public boolean validateToken() -
rest
-
extensionManager
- Specified by:
extensionManager
in interfaceCatnip
- Returns:
- The extension manager being used by this catnip instance.
-
keepaliveThread
-
latch
-
startedKeepalive
public boolean startedKeepalive() -
options
-
entityBuilder
Description copied from interface:Catnip
The entity builder used by this catnip instance. This is exposed publicly so that, if necessary, it can be used to construct entities from JSON objects as needed.- Specified by:
entityBuilder
in interfaceCatnip
- Returns:
- This catnip instance's
EntityBuilder
.
-