Record Class DiscordChannelConfig
- Record Components:
botToken- Discord bot token (noBotprefix — the channel adds it). Required.applicationId- Application ID for slash command registration. Optional; v1 doesn't use it but a consumer's configuration may carry it for forward-compat.restBaseUrl- base URL for the Discord REST API. Defaults tohttps://discord.com/api/v10; tests override this to point at a MockWebServer. Always lacks a trailing slash.intents- Gateway intents bitfield. Defaults toDEFAULT_INTENTSwhich covers DM + guild messages + message content.reconnectInitialBackoff- initial WebSocket reconnect delay.reconnectMaxBackoff- cap for reconnect delay.
DiscordChannel.
Discord auth uses a single bot token (the Authorization: Bot ...
header value, prefixed without quoting) for both the REST API
(POST /channels/:id/messages) and the Gateway WebSocket
(IDENTIFY payload). The application ID is only needed when
registering slash commands — scoped out of v1 — so this record
carries it as optional metadata.
Intents bitfield: Discord requires the client to declare which
event categories it wants in the IDENTIFY payload. v1 needs
GUILDS (1), GUILD_MESSAGES (512), DIRECT_MESSAGES
(4096), and the privileged MESSAGE_CONTENT (32768) to
read the actual message text — the last must be enabled separately
in the Discord developer portal for the bot.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intGUILDS (1) | GUILD_MESSAGES (512) | DIRECT_MESSAGES (4096) | MESSAGE_CONTENT (32768).static final DurationDefault initial reconnect delay — 1s.static final DurationDefault max reconnect delay — 60s.static final StringDefault base URL for the Discord REST API (v10). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theapplicationIdrecord component.botToken()Returns the value of thebotTokenrecord component.final booleanIndicates whether some other object is "equal to" this one.static Optional<DiscordChannelConfig> Populate from environment variables.final inthashCode()Returns a hash code value for this object.intintents()Returns the value of theintentsrecord component.Returns the value of thereconnectInitialBackoffrecord component.Returns the value of thereconnectMaxBackoffrecord component.Returns the value of therestBaseUrlrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT_REST_BASE_URL
Default base URL for the Discord REST API (v10).- See Also:
-
DEFAULT_INTENTS
public static final int DEFAULT_INTENTSGUILDS (1) | GUILD_MESSAGES (512) | DIRECT_MESSAGES (4096) | MESSAGE_CONTENT (32768).- See Also:
-
DEFAULT_RECONNECT_INITIAL
Default initial reconnect delay — 1s. -
DEFAULT_RECONNECT_MAX
Default max reconnect delay — 60s.
-
-
Constructor Details
-
DiscordChannelConfig
public DiscordChannelConfig(String botToken, String applicationId, String restBaseUrl, int intents, Duration reconnectInitialBackoff, Duration reconnectMaxBackoff) Creates an instance of aDiscordChannelConfigrecord class.- Parameters:
botToken- the value for thebotTokenrecord componentapplicationId- the value for theapplicationIdrecord componentrestBaseUrl- the value for therestBaseUrlrecord componentintents- the value for theintentsrecord componentreconnectInitialBackoff- the value for thereconnectInitialBackoffrecord componentreconnectMaxBackoff- the value for thereconnectMaxBackoffrecord component
-
-
Method Details
-
fromEnvironment
Populate from environment variables. Missing the requiredDISCORD_BOT_TOKENreturnsOptional.empty()so the channel can decline to start without throwing.Recognised vars:
DISCORD_BOT_TOKEN(required),DISCORD_APPLICATION_ID(optional, slash commands),DISCORD_REST_BASE_URL(optional override for mirrors / API-version pinning),DISCORD_INTENTS(optional, integer override of the gateway intents bitfield). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
botToken
Returns the value of thebotTokenrecord component.- Returns:
- the value of the
botTokenrecord component
-
applicationId
Returns the value of theapplicationIdrecord component.- Returns:
- the value of the
applicationIdrecord component
-
restBaseUrl
Returns the value of therestBaseUrlrecord component.- Returns:
- the value of the
restBaseUrlrecord component
-
intents
public int intents()Returns the value of theintentsrecord component.- Returns:
- the value of the
intentsrecord component
-
reconnectInitialBackoff
Returns the value of thereconnectInitialBackoffrecord component.- Returns:
- the value of the
reconnectInitialBackoffrecord component
-
reconnectMaxBackoff
Returns the value of thereconnectMaxBackoffrecord component.- Returns:
- the value of the
reconnectMaxBackoffrecord component
-