Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/discordeno/gateway/mod.ts>CreateShard

Discord API library for Deno
Extremely Popular
Go to Latest
interface CreateShard
Re-export
import { type CreateShard } from "https://deno.land/x/discordeno@17.0.0/gateway/mod.ts";

Properties

id: number

Id of the shard which should be created.

gatewayConfig: PickPartial<ShardGatewayConfig, "token">

Gateway configuration for the shard.

totalShards: number

The total amount of shards which are used to communicate with Discord.

requestIdentify: (shardId: number) => Promise<void>

This function communicates with the management process, in order to know whether its free to identify. When this function resolves, this means that the shard is allowed to send an identify payload to discord.

optional
calculateSafeRequests: calculateSafeRequests

Calculate the amount of requests which can safely be made per rate limit interval, before the gateway gets disconnected due to an exceeded rate limit.

optional
close: close

Close the socket connection to discord if present.

optional
connect: connect

Connect the shard with the gateway and start heartbeating. This will not identify the shard to the gateway.

optional
handleClose: handleClose
optional
handleMessage: handleMessage
optional
identify: identify

Identify the shard to the gateway. If not connected, this will also connect the shard to the gateway.

optional
isOpen: isOpen

Check whether the connection to Discord is currently open.

optional
maxRequestsPerRateLimitTick: number

The maximum of requests which can be send to discord per rate limit tick. Typically this value should not be changed.

optional
previousSequenceNumber: number

The previous payload sequence number.

optional
rateLimitResetInterval: number

In which interval (in milliseconds) the gateway resets it's rate limit.

optional
resume: resume

Attempt to resume the previous shards session with the gateway.

optional
send: send

Send a message to Discord.

optional
shutdown: shutdown

Shutdown the shard. Forcefully disconnect the shard from Discord. The shard may not attempt to reconnect with Discord.

optional
startHeartbeating: startHeartbeating
optional
state: ShardState

Current internal state of the shard.

optional
stopHeartbeating: stopHeartbeating
optional
events: ShardEvents

The shard related event handlers.

optional
heart: ShardHeart

This contains all the heartbeat information

optional
bucket: LeakyBucket

Bucket for handling shard request rate limits.

optional
offlineSendQueue: ShardSocketRequest[]

Cache for pending gateway requests which should have been send while the gateway went offline.

optional
resolves: Shard["resolves"]

This is used to resolve internal waiting states. Mapped by SelectedEvents => ResolveFunction

Methods

optional
makePresence(shardId: number): Promise<StatusUpdate> | StatusUpdate

Function which can be overwritten in order to get the shards presence.