Skip to main content

Module manager

Module manager 

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

ApplicationEmojiManager
The emojis of the bot’s application, usable by the bot in every guild. Returned by Context::application_emojis.
AutoModerationRuleManager
The auto moderation rules of one guild. Returned by Context::auto_moderation_rules.
BanManager
The bans of one guild. Returned by Context::bans.
ChannelManager
The channels the bot can see, by ID. Returned by Context::channels.
CommandManager
The bot’s global application commands. Returned by Context::commands.
EmojiManager
The custom emojis of one guild. Returned by Context::emojis.
Fetch
A fetch that 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 call force first to always ask Discord.
FetchFuture
The future of an awaited Fetch.
FetchMembers
A request of guild members through the gateway, not sent yet: configure it, then .await it. Made by MemberManager::fetch_all, fetch_by_query and fetch_many (D-270).
FetchedThreads
A list of threads from Discord: active or archived ones (discord.js: FetchedThreads).
GuildChannelManager
The channels of one guild, as a whole (D-234). Returned by Context::guild_channels.
GuildCommandManager
The bot’s application commands in one guild, and the command permissions there. Returned by Context::guild_commands.
GuildManager
The guilds of the bot. Returned by Context::guilds.
InviteManager
Invites, by code (D-239). Returned by Context::invites.
MemberManager
The members of one guild. Returned by Context::members.
MessageManager
The messages of one channel. Returned by Context::messages.
RoleManager
The roles of one guild. Returned by Context::roles.
ScheduledEventManager
The scheduled events of one guild. Returned by Context::scheduled_events.
SoundboardSoundManager
The soundboard sounds of one guild. Returned by Context::soundboard_sounds; Discord’s default sounds are listed by Context::default_soundboard_sounds (D-243).
StageInstanceManager
The live stages of one guild, by their stage channel. Returned by Context::stage_instances.
StickerManager
The stickers of one guild. Returned by Context::stickers.
ThreadManager
The threads of one parent channel: creating them and listing the archived ones. Returned by Context::threads.
ThreadMemberManager
The members of one thread. Returned by Context::thread_members.
UserManager
The users the bot knows. Returned by Context::users.
WebhookManager
Webhooks, by ID (D-237). Returned by Context::webhooks.

Enums§

GatewayRequestError
Why a request answered through the gateway failed.
OverwriteTarget
Whose permissions a channel overwrite changes (D-235): built from a RoleId or a UserId.

Type Aliases§

GuildSoundboardSounds
The soundboard sounds of several guilds, by guild and sound.