Resources and permissions
Resource helpers wrap API responses with methods such aschannel.send() and
guild.members.fetch(). They use the same REST client, queues, and rate limits as
client.rest.request().
Fetch a resource
signal, timeoutMs, and reason options. .data holds
the frozen API response; convenience getters use camelCase, such as
channel.guildId, while raw fields keep their API names.
Resource objects are snapshots. A gateway update or a call to edit() does not
rewrite an object you already hold. Use the returned object or fetch again.
For a direct message, fetch a user and call send():
Iterate members
limit, it continues
until the API has no more pages. guild.members.list() fetches one page and
accepts { limit, after }, with a numeric page limit.
Enable caches when you need them
All client caches are disabled by default. Capacities count entries, andttlMs
applies to each cache:
fetch() always makes an API request. To use a cached channel, check it explicitly:
channel.guild only reads the guild cache and may
be undefined; fetch the guild explicitly if you need it.
client.cache is the separate message cache. Keys are
${channelId}:${messageId}. It receives MESSAGE_CREATE events, merges updates
into existing entries, and removes deleted messages. Fetching or sending a message
does not populate it. A new READY, terminal gateway closure, or disconnect()
clears the client’s caches; a successful Resume preserves them.
Check channel permissions
Load the member, the guild’s full role list, and the channel’s overwrites before calculating permissions:isTimedOut(), canManageRole(), and canDeleteRole() cover some of those checks.
Permission flags are bigint values. Use Permissions.toRequest() when building
a role or overwrite request; it returns a decimal string containing the defined
permission bits. Converting masks to JavaScript numbers can lose precision.
For an endpoint without a resource helper, use the typed REST client.