Some issues with the shard manager:
- The client was checking for a `shardConcurrency` option for some
reason under `connect()`
- Shards wait until its ready then wait 5s before connecting another
shard rather than waiting 5s after sending an identify packet
- The default create timeout being 2 seconds is, ehh, slow? There
usually isnt such a large delay between these events
- Waiting for shards to be ready is bound by the client's unavailable
guilds rather than it's own list of guilds to wait for
So this PR changes some things:
- Reworks the connection strategy, it will wait 5s after sending the
identify packet before connecting another shard in it's bucket, the
`connectTimeout` waits until the next best moment to check over shards
again. Also it was just iterating the queue while it could be altered
- Shards now hold their own "awaited guilds" set for those IDs to be
expected to come in before it is considered as ready
- `guildCreateTimeout`: 2 seconds -> 1 second
---------
Co-authored-by: TTtie <me@tttie.cz>
- Removes duplicate JSON/ETF parse code from the compressed data
pipeline, making the code easier to read.
- Forces ArrayBuffers converesion to Node buffers unconditionally.
Migrates Dysnomia over to pnpm. Might also do some housekeeping while at
it.
Short list of changes: (entries will be added here as needed)
- Migrated to pnpm. CI has been updated relatively blindly and will need
some testing beforehand.
- A lock file is now included for local development
- Actions are pinned to their commit SHA
- Updated some dependencies
- tsconfig.json now targets ES2025 + modern Node.js module resolution
-
- Makes .webp the default image format for both static and animated
images
- Discord documentation states that assets uploaded as animated
.webp/.avif aren't converted to other formats. (see ref)
- Although static .webp is still converted to other formats, using a
single image format makes matters a bit more consistent
- This is obviously a breaking change for users that expect to get a
.jpg/.gif out of the URL getters. Most reasonably modern image
processing toolkits should be able to take .webp media just fine though.
- .webp links will now contain the `?animated=true` query string
parameter for animated images
- An additional boolean parameter has been added to `dynamic[...]URL()`
APIs to exclude the parameter, forcing a static version of the image.
- Added some missing dynamic URL APIs, namely `Role#dynamicIconURL` and
`GuildScheduledEvent#dynamicImageURL`
Ref:
https://github.com/discord/discord-api-docs/commit/ab3ea3c8d7a7c5ddc6b991f409355b4fa86bc9b3
Automatically ensures `Client#application` is present for methods that
need the data from it to function.
This enables more seamless usage in REST-only scripts to set commands
up, for example. However, if desired, `Client#application` can be still
populated with known data to avoid a roundtrip to the API.
Updates the workflows to use their latest version, along some
consistency fixes.
Additionally, when releasing, the built tarball won't be rezipped again.
This should allow for not using the `Client.channelGuildMap`,
`Client.threadGuildMap`, and `Client.guildShardMap` when
`caching.disableMaps` is on.
Some caveats:
- Obviously `getChannel` will do linear searching now, but this can be
skipped with guild hinting. `getChannel` now has a `guildIDHint`
parameter for getting that specific guild rather than searching all of
them. Which has some caveats:
- `editChannelPosition`'s option param has `guildIDHint`, it's channel's
corresponding function will use it.
- Same for `joinVoiceChannel` and `leaveVoiceChannel`, but
`leaveVoiceChannel` has it's hinting in a new parameter.
- `ThreadMember`'s construction to find the guild *will* do linear
searching, sad.
- Many of the shard events that use `getChannel` either now hint at the
guild or just gets the guild directly.
---------
Co-authored-by: TTtie <me@tttie.cz>
Had this crash on a bot due to it getting a wrong epoch in the message.
Don't know if thats a davey bug or not, but the library should try to
recover if it can. I'm asking Discord staff whats the optional way to
mitigate this later.
This is rare, but sometimes some packets are given with *only* padding
inside them, #229 fixed the issue of handling padding properly so that
it's not passed to the `data` event, but empty buffers while in a DAVE
session leads to failed decryptions. This usually occurs in
Cloudflare-ran voice servers.