Interface CatnipOptionsView
- All Known Implementing Classes:
CatnipOptions
CatnipOptions
.- Since:
- 10/18/19.
- Author:
- amy
-
Method Summary
Modifier and TypeMethodDescriptionapiHost()
The host used for Discord API requests.int
The cache worker for catnip to use.boolean
Whether or not catnip should capture REST stacktraces before running REST requests.boolean
Whether or not catnip should chunk members.How catnip compresses incoming events from Discord.com.grack.nanojson.JsonObject
The events that catnip should not emit.Manages event dispatching and consumers.boolean
Whether or not catnip should emit full event objects.boolean
Whether or not Discord should subscribe to guild workers and provide stuff such as presence updates, typing events, member updates and other stuff, see discord-api-docs#1016 for more information.boolean
Whether or not catnip should enforce permissions for REST actions.The entity serializer that catnip uses for de/serializing entities for external usage.The event buffer for catnip to use.The gateway ratelimiter for catnip to use.long
If heartbeat latency takes longer than this much time, catnip will emit aHighWebsocketLatency
event containing information about which shard is experiencing high latency and how high the latency is.
This value is specified in nanoseconds.The HTTP client that catnip uses internally for websockets and REST requests.The presence that catnip should set for shards as they log in.intents()
boolean
int
Total number of members where the gateway will stop sending offline members in the guild member list.The log adapter for catnip to use.boolean
boolean
boolean
Whether or not extensions overriding options should be logged.boolean
If this option is enabled, lifecycle-related events -- things like shard connects / disconnects, 429 HTTP responses, ...boolean
boolean
Whether or not to log "Received presence for uncached user XXX" when catnip is not chunking members.boolean
If this option is enabled, emit aMemberChunkRerequest
over the event bus when a shard needs to re-request member chunks for a guild, instead of automatically re-requesting them.long
How long catnip should wait to ensure that all member chunks have been received, in milliseconds.The application's public key.The requester catnip uses for REST requests.boolean
Whether or not catnip should assume the inability to have a properly synchronized clock when computing REST ratelimits.io.reactivex.rxjava3.core.Scheduler
The RxJava scheduler that catnip should use for scheduling things like stream subscriptions.The session manager for catnip to use.The shard manager for catnip to use.The task scheduler that catnip will use for scheduling its own internal tasks.token()
The token for catnip to use.boolean
Whether or not to validate the provided token when setting up catnip.
-
Method Details
-
token
The token for catnip to use.May not be overridden by extensions.
-
publicKey
The application's public key. Used for interactions (think slash commands).May not be overriden by extensions.
-
shardManager
The shard manager for catnip to use. Defaults toDefaultShardManager
. -
sessionManager
The session manager for catnip to use. Defaults toDefaultSessionManager
-
gatewayRatelimiter
The gateway ratelimiter for catnip to use. Defaults toMemoryRatelimiter
-
logAdapter
The log adapter for catnip to use. Defaults toDefaultLogAdapter
, which uses SLF4J. -
eventBuffer
The event buffer for catnip to use. Defaults toCachingBuffer
. If you want to use an alternative event buffering strategy (ex. no buffering, only buffer certain events, ...) you can write your own implementation. For no buffering,NoopBuffer
is provided.Do NOT change this if you don't know what you're doing!
-
cacheWorker
The cache worker for catnip to use. Defaults toSplitMemoryEntityCache
. Change this if you want to use your ownEntityCacheWorker
. -
dispatchManager
Manages event dispatching and consumers. Defaults toDefaultDispatchManager
. -
chunkMembers
boolean chunkMembers()Whether or not catnip should chunk members. Do not disable this if you don't know what it does. -
emitEventObjects
boolean emitEventObjects()Whether or not catnip should emit full event objects. Do not disable this if you don't know what it does. Mainly only useful for ex. anExtension
that does things with the raw gateway payloads, like sending them to a message queue. -
enforcePermissions
boolean enforcePermissions()Whether or not catnip should enforce permissions for REST actions. Note that this will NOT enforce permissions if you directly call methods viaCatnip.rest()
, but will enforce them if you call them from entity objects (ex. doingGuild.delete()
). -
initialPresence
The presence that catnip should set for shards as they log in. This is for setting whether your bot appears online/DND/away/offline, as well as the "playing XXX" status. -
disabledEvents
The events that catnip should not emit. You can useDiscordEvent.Raw
to get the event names. -
requester
The requester catnip uses for REST requests. Defaults toSerialRequester
. -
logExtensionOverrides
boolean logExtensionOverrides()Whether or not extensions overriding options should be logged. Defaults totrue
.May not be overridden by extensions.
-
validateToken
boolean validateToken()Whether or not to validate the provided token when setting up catnip. It is HIGHLY recommended that you leave this with the default setting.May not be overridden by extensions.
-
captureRestStacktraces
boolean captureRestStacktraces()Whether or not catnip should capture REST stacktraces before running REST requests.catnip runs REST requests asynchronously. Because of this, we lose the caller's stacktrace, and exceptions thrown from REST calls are lost to the ether basically. If this option is enabled, catnip will capture a stacktrace before REST requests, and make it available to any exceptions thrown by the REST handler.
NOTE: Capturing stacktraces is s l o w. If you have performance problems around REST requests, you can disable this, at the cost of losing debuggability. Note that it may be useful to add
-XX:-OmitStackTraceInFastThrow
to your JVM flags to ensure that this doesn't get optimized out.TODO: Verify that -XX:-OmitStackTraceInFastThrow isn't needed now.
-
logUncachedPresenceWhenNotChunking
boolean logUncachedPresenceWhenNotChunking()Whether or not to log "Received presence for uncached user XXX" when catnip is not chunking members. Basically, this avoids a ton of logspam. -
enableGuildSubscriptions
boolean enableGuildSubscriptions()Whether or not Discord should subscribe to guild workers and provide stuff such as presence updates, typing events, member updates and other stuff, see discord-api-docs#1016 for more information. -
memberChunkTimeout
long memberChunkTimeout()How long catnip should wait to ensure that all member chunks have been received, in milliseconds. If all member chunks still haven't been received after this period, member chunking will be re-requested, to try to make sure we're not missing any. -
rxScheduler
@Nonnull io.reactivex.rxjava3.core.Scheduler rxScheduler()The RxJava scheduler that catnip should use for scheduling things like stream subscriptions. Defaults toRxHelpers.FORK_JOIN_SCHEDULER
. -
logLifecycleEvents
boolean logLifecycleEvents()If this option is enabled, lifecycle-related events -- things like shard connects / disconnects, 429 HTTP responses, ... -- will be directly logged via the configuredlogAdapter()
, in addition to being emitted over the event bus. -
manualChunkRerequesting
boolean manualChunkRerequesting()If this option is enabled, emit aMemberChunkRerequest
over the event bus when a shard needs to re-request member chunks for a guild, instead of automatically re-requesting them. -
largeThreshold
int largeThreshold()Total number of members where the gateway will stop sending offline members in the guild member list. If a guild's member count is over this limit, member chunking will happen. SeechunkMembers()
manualChunkRerequesting()
memberChunkTimeout()
for more. This must be between 50 and 250.For Discord's documentation, go here: https://discord.com/developers/docs/topics/gateway#identify-identify-structure
-
taskScheduler
The task scheduler that catnip will use for scheduling its own internal tasks. This scheduler is exposed to the outside world throughCatnip.taskScheduler()
, and can safely be used for any task scheduling needs you may have. Defaults toRxTaskScheduler
. -
httpClient
The HTTP client that catnip uses internally for websockets and REST requests. Defaults to an instance that usesRxHelpers.FORK_JOIN_POOL
as its executor. -
compressionMode
How catnip compresses incoming events from Discord. Default isCompressionMode.ZLIB
. -
restRatelimitsWithoutClockSync
boolean restRatelimitsWithoutClockSync()Whether or not catnip should assume the inability to have a properly synchronized clock when computing REST ratelimits. When this option is set totrue
, catnip will assume that the local clock cannot be properly synced, and will use a less-efficient method provided by Discord for computing REST ratelimits. See https://github.com/discord/discord-api-docs/pull/1069 for more info. -
highLatencyThreshold
long highLatencyThreshold()If heartbeat latency takes longer than this much time, catnip will emit aHighWebsocketLatency
event containing information about which shard is experiencing high latency and how high the latency is.
This value is specified in nanoseconds. -
entitySerializer
The entity serializer that catnip uses for de/serializing entities for external usage. The value of this option will not affect how catnip behaves internally, but rather will affect user-controlled serialization for interfacing with the outside world. -
apiHost
The host used for Discord API requests. Defaults tohttps://discord.com
. Changing this is only really useful for the case of ex. running tests against a local mock API. Providing the protocol is REQUIRED. -
apiVersion
@Nonnegative int apiVersion()- Returns:
- The version of the Discord REST API to use. Defaults to
6
. Changing this is really only useful for the case of ex. running tests against a local mock API. Note that catnip is not tested against API v7, nor is v7 actively supported at this time.
-
intents
- Returns:
- The set of gateway intents that this bot wishes to use. This is
OPTIONAL as of gateway v6, but will be REQUIRED in gateway v7.
Gateway intents are used to control the events that your bot receives. Intents are relatively-broad categories of events; see the documentation on each member ofGatewayIntent
for more information about what events are covered by each intent.
NOTE THAT THIS IS NOT THE SAME ASdisabledEvents()
!
-
logPrivilegedIntentWarning
boolean logPrivilegedIntentWarning()- Returns:
- Whether or not to log a warning about the use of privileged
GatewayIntent
s. Defaults totrue
.
-
customIdentifyOptions
@Nullable com.grack.nanojson.JsonObject customIdentifyOptions()- Returns:
- Custom
IDENTIFY
options to pass to the gateway when connecting. Useful for adding support for new features that catnip doesn't yet support. Defaults tonull
.
-
entityDelegator
- Returns:
- The delegator used to delegate catnip entities into a custom wrapper entity. Defaults to the identity function.
-
logEventNotInIntentsWarning
boolean logEventNotInIntentsWarning()- Returns:
- Whether or not a warning should be logged when attempting to
listen on an event that the current intents do not allow listening on.
Defaults to
true
.
-
logEntityPresenceWarningOnCustomCache
boolean logEntityPresenceWarningOnCustomCache()- Returns:
- Whether or not to log a warning when an entity is not present
in a
CustomizableEntityCache
implementation when it should be. This is useful for debugging a custom cache, while also hiding potential errors that may come fromNoopEntityCache
.
-
iReallyWantToStartTheBotWithNoIntents
boolean iReallyWantToStartTheBotWithNoIntents()- Returns:
- Whether or not you can initialise a
Catnip
instance with no intents.
-