Interface CatnipOptionsView

All Known Implementing Classes:
CatnipOptions

public interface CatnipOptionsView
An immutable view of CatnipOptions.
Since:
10/18/19.
Author:
amy
  • Method Details

    • token

      @Nonnull String token()
      The token for catnip to use.

      May not be overridden by extensions.

    • publicKey

      @Nullable String publicKey()
      The application's public key. Used for interactions (think slash commands).

      May not be overriden by extensions.

    • shardManager

      @Nonnull ShardManager shardManager()
      The shard manager for catnip to use. Defaults to DefaultShardManager.
    • sessionManager

      @Nonnull SessionManager sessionManager()
      The session manager for catnip to use. Defaults to DefaultSessionManager
    • gatewayRatelimiter

      @Nonnull Ratelimiter gatewayRatelimiter()
      The gateway ratelimiter for catnip to use. Defaults to MemoryRatelimiter
    • logAdapter

      @Nonnull LogAdapter logAdapter()
      The log adapter for catnip to use. Defaults to DefaultLogAdapter, which uses SLF4J.
    • eventBuffer

      @Nonnull EventBuffer eventBuffer()
      The event buffer for catnip to use. Defaults to CachingBuffer. 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

      @Nonnull EntityCacheWorker cacheWorker()
      The cache worker for catnip to use. Defaults to SplitMemoryEntityCache. Change this if you want to use your own EntityCacheWorker.
    • dispatchManager

      @Nonnull DispatchManager dispatchManager()
      Manages event dispatching and consumers. Defaults to DefaultDispatchManager.
    • 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. an Extension 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 via Catnip.rest(), but will enforce them if you call them from entity objects (ex. doing Guild.delete()).
    • initialPresence

      @Nullable Presence 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

      @Nonnull Set<String> disabledEvents()
      The events that catnip should not emit. You can use DiscordEvent.Raw to get the event names.
    • requester

      @Nonnull Requester requester()
      The requester catnip uses for REST requests. Defaults to SerialRequester.
    • logExtensionOverrides

      boolean logExtensionOverrides()
      Whether or not extensions overriding options should be logged. Defaults to true.

      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 to RxHelpers.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 configured logAdapter(), in addition to being emitted over the event bus.
    • manualChunkRerequesting

      boolean manualChunkRerequesting()
      If this option is enabled, emit a MemberChunkRerequest 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. See chunkMembers() 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

      @Nonnull TaskScheduler taskScheduler()
      The task scheduler that catnip will use for scheduling its own internal tasks. This scheduler is exposed to the outside world through Catnip.taskScheduler(), and can safely be used for any task scheduling needs you may have. Defaults to RxTaskScheduler.
    • httpClient

      @Nonnull HttpClient httpClient()
      The HTTP client that catnip uses internally for websockets and REST requests. Defaults to an instance that uses RxHelpers.FORK_JOIN_POOL as its executor.
    • compressionMode

      @Nonnull CompressionMode compressionMode()
      How catnip compresses incoming events from Discord. Default is CompressionMode.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 to true, 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 a HighWebsocketLatency event containing information about which shard is experiencing high latency and how high the latency is.
      This value is specified in nanoseconds.
    • entitySerializer

      @Nonnull EntitySerializer<?> 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

      @Nonnull String apiHost()
      The host used for Discord API requests. Defaults to https://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

      @Nonnull Set<GatewayIntent> 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 of GatewayIntent for more information about what events are covered by each intent.
      NOTE THAT THIS IS NOT THE SAME AS disabledEvents()!
    • logPrivilegedIntentWarning

      boolean logPrivilegedIntentWarning()
      Returns:
      Whether or not to log a warning about the use of privileged GatewayIntents. Defaults to true.
    • 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 to null.
    • entityDelegator

      @Nonnull EntityDelegator 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 from NoopEntityCache.
    • iReallyWantToStartTheBotWithNoIntents

      boolean iReallyWantToStartTheBotWithNoIntents()
      Returns:
      Whether or not you can initialise a Catnip instance with no intents.