Skip to main content

Resource objects

Import these classes from talos-fluxer or talos-fluxer/resources. Prefer obtaining them through a manager rather than constructing API payloads yourself. See the resource guide and source. UserResource, Channel, Guild, GuildMember, and Role inherit data, a frozen API snapshot, and toJSON(), which returns that snapshot. A fetch or edit returns a new object. REST operation options accept signal, timeoutMs, and reason; message options also accept files.

Resources

Available as client.resources. To use the helpers without a gateway, construct new Resources(() => rest, cacheOptions?). The REST client must already exist. Cache options are users, channels, guilds, members, roles, and ttlMs. Capacities default to zero and TTL to five minutes. Managers scoped to a guild share these caches. Client calls apply() automatically; REST-only code receives no gateway updates unless the application supplies them.

UserResource

Obtain with client.users.fetch(userId) or resources.users.wrap(data). Constructor: new UserResource(data, resources). Properties: id, username, and inherited data and toJSON().

Channel

Obtain with client.channels.fetch(channelId). Constructor: new Channel(data, resources). Properties: id, guildId (string or null), type (number), name (string or null), guild (Guild or undefined), plus inherited data and toJSON(). guild reads the cache only; it does not fetch. History and send options match the Messages manager. Permission calculation requires a member from this channel’s guild and the full role list. Direct-message channels have no guild permission mask to calculate.

Guild

Obtain with client.guilds.fetch(guildId). Constructor: new Guild(data, resources). Properties: id, name, ownerId, roles (Roles manager), members (Members manager), and inherited data and toJSON(). The member passed to permissionsFor() must belong to this guild. Use Channel.permissionsFor() when channel overwrites matter.

GuildMember

Obtain with guild.members.fetch(userId). Constructor: new GuildMember(guildId, data, resources). Properties: guildId, id (the user ID), user (UserResource), displayName, and inherited data and toJSON(). The display name uses nickname, then global name, then username. Role changes do not mutate this snapshot. Fetch again when you need the updated role list. The server enforces moderation permissions and role hierarchy.

Role

Obtain from guild.roles.list() or guild.roles.create(body). Constructor: new Role(guildId, data, resources). Properties: guildId, id, name, permissions (Permissions), and inherited data and toJSON(). Use Permissions.toRequest() when writing permission masks into role requests.