Skip to main content

Module ext

Module ext 

Source
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.

TraitImplemented for
MessageExtMessage, CachedMessage
ChannelExtChannel (also the cached type)
UserExtUser, CachedUser
MemberExtCachedMember, the GuildMemberAdd and GuildMemberUpdate payloads (the model Member does not know its guild)
GuildExtGuild, CachedGuild
WebhookExtWebhook
InteractionExtInteraction (and so the InteractionCreate payload), the router’s wrappers

Import the traits with prelude.

Traits§

ChannelExt
Actions on a Channel (the model type, which is also the type the cache keeps).
GuildExt
Actions on a guild: Guild or CachedGuild.
InteractionExt
Responses to an Interaction (D-248): one method per Discord callback, plus the original response and follow-up messages. Works on the InteractionCreate payload too, which dereferences to the interaction.
MemberExt
Actions on a guild member: CachedMember, or the payload of Events::GuildMemberAdd or Events::GuildMemberUpdate.
MessageExt
Actions on a message: Message or CachedMessage.
UserExt
Actions on a user: User or CachedUser.
WebhookExt
Actions on a Webhook (D-237, D-240).