Expand description
Methods on Discord structures (discord.js-style “structures” behaviour, D-220).
djs-rs keeps the data types of djs-model and djs-cache plain and adds behaviour through
extension traits that take the handler Context explicitly — msg.reply(&ctx, "Pong!") —
instead of storing a client reference inside every structure as discord.js does. This keeps
structures small, Clone cheap and free of reference cycles.
Each trait is implemented for the model type and the cached type (D-233), and so works on
anything that dereferences to one of them, such as event payloads. The methods delegate to
the managers and return what they return: the cached type in an Arc.
| Trait | Implemented for |
|---|---|
MessageExt | Message, CachedMessage |
ChannelExt | Channel (also the cached type) |
UserExt | User, CachedUser |
MemberExt | CachedMember, the GuildMemberAdd and GuildMemberUpdate payloads (the model Member does not know its guild) |
GuildExt | Guild, CachedGuild |
WebhookExt | Webhook |
InteractionExt | Interaction (and so the InteractionCreate payload), the router’s wrappers |
Import the traits with prelude.
Traits§
- Channel
Ext - Actions on a
Channel(the model type, which is also the type the cache keeps). - Guild
Ext - Actions on a guild:
GuildorCachedGuild. - Interaction
Ext - Responses to an
Interaction(D-248): one method per Discord callback, plus the original response and follow-up messages. Works on theInteractionCreatepayload too, which dereferences to the interaction. - Member
Ext - Actions on a guild member:
CachedMember, or the payload ofEvents::GuildMemberAddorEvents::GuildMemberUpdate. - Message
Ext - Actions on a message:
MessageorCachedMessage. - UserExt
- Actions on a user:
UserorCachedUser. - Webhook
Ext - Actions on a
Webhook(D-237, D-240).