Expand description
Managers: the operations of one resource, reached from the Context (D-229).
// The cache first, then the REST API; the REST result is cached (D-230).
let member = ctx.members(guild).fetch(user).await?;
println!("{} joined at {:?}", member.user.username, member.joined_at);
// Always ask Discord.
let fresh = ctx.members(guild).fetch(user).force().await?;
// Lists are `Collection`s in Discord's order (D-231).
let roles = ctx.roles(guild).list().await?;
let hoisted = roles.filter(|role, _| role.hoist);§What managers return
The type the cache stores (D-233): Arc<CachedMember>, Arc<CachedMessage>,
Arc<CachedGuild>, Arc<CachedUser> for the compact cached types, Arc<Channel> and
Arc<Role> where the cache keeps the model type — whether the value came from the cache or
from Discord. A REST result is converted to that type and stored when its resource is
enabled in the CacheConfig; without a cache it is only
converted. Objects the cache never keeps (bans) are returned as their
djs-model type.
Managers are small Copy values borrowing the context; their methods consume them, so
ctx.members(guild).kick(user, None).await needs no binding.
discord.js counterpart: the *Manager classes (GuildMemberManager, MessageManager, …).
Structs§
- Application
Emoji Manager - The emojis of the bot’s application, usable by the bot in every guild. Returned by
Context::application_emojis. - Auto
Moderation Rule Manager - The auto moderation rules of one guild. Returned by
Context::auto_moderation_rules. - BanManager
- The bans of one guild. Returned by
Context::bans. - Channel
Manager - The channels the bot can see, by ID. Returned by
Context::channels. - Command
Manager - The bot’s global application commands. Returned by
Context::commands. - Emoji
Manager - The custom emojis of one guild. Returned by
Context::emojis. - Fetch
- A
fetchthat is not sent yet: await it to read the cache first and ask Discord when the cache does not hold the value (D-230), or callforcefirst to always ask Discord. - Fetch
Future - The future of an awaited
Fetch. - Fetch
Members - A request of guild members through the gateway, not sent yet: configure it, then
.awaitit. Made byMemberManager::fetch_all,fetch_by_queryandfetch_many(D-270). - Fetched
Threads - A list of threads from Discord: active or archived ones (discord.js:
FetchedThreads). - Guild
Channel Manager - The channels of one guild, as a whole (D-234). Returned by
Context::guild_channels. - Guild
Command Manager - The bot’s application commands in one guild, and the command permissions there.
Returned by
Context::guild_commands. - Guild
Manager - The guilds of the bot. Returned by
Context::guilds. - Invite
Manager - Invites, by code (D-239). Returned by
Context::invites. - Member
Manager - The members of one guild. Returned by
Context::members. - Message
Manager - The messages of one channel. Returned by
Context::messages. - Role
Manager - The roles of one guild. Returned by
Context::roles. - Scheduled
Event Manager - The scheduled events of one guild. Returned by
Context::scheduled_events. - Soundboard
Sound Manager - The soundboard sounds of one guild. Returned by
Context::soundboard_sounds; Discord’s default sounds are listed byContext::default_soundboard_sounds(D-243). - Stage
Instance Manager - The live stages of one guild, by their stage channel. Returned by
Context::stage_instances. - Sticker
Manager - The stickers of one guild. Returned by
Context::stickers. - Thread
Manager - The threads of one parent channel: creating them and listing the archived ones.
Returned by
Context::threads. - Thread
Member Manager - The members of one thread. Returned by
Context::thread_members. - User
Manager - The users the bot knows. Returned by
Context::users. - Webhook
Manager - Webhooks, by ID (D-237). Returned by
Context::webhooks.
Enums§
- Gateway
Request Error - Why a request answered through the gateway failed.
- Overwrite
Target - Whose permissions a channel overwrite changes (D-235): built from a
RoleIdor aUserId.
Type Aliases§
- Guild
Soundboard Sounds - The soundboard sounds of several guilds, by guild and sound.