Skip to main content

ChannelExt

Trait ChannelExt 

Source
pub trait ChannelExt: Channel {
Show 19 methods // Provided methods fn messages<'a, B: Backend>( &self, ctx: &'a Context<B>, ) -> MessageManager<'a, B> { ... } fn send<B: Backend>( &self, ctx: &Context<B>, body: impl Into<CreateMessage>, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send { ... } fn send_typing<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<(), Error>> + Send { ... } fn bulk_delete<B: Backend>( &self, ctx: &Context<B>, message_ids: Vec<MessageId>, reason: Option<&str>, ) -> impl Future<Output = Result<(), Error>> + Send { ... } fn edit<B: Backend>( &self, ctx: &Context<B>, body: &ModifyGuildChannel, reason: Option<&str>, ) -> impl Future<Output = Result<Arc<Channel>, Error>> + Send { ... } fn delete<B: Backend>( &self, ctx: &Context<B>, reason: Option<&str>, ) -> impl Future<Output = Result<Channel, Error>> + Send { ... } fn set_permissions<B: Backend>( &self, ctx: &Context<B>, target: impl Into<OverwriteTarget>, allow: Permissions, deny: Permissions, reason: Option<&str>, ) -> impl Future<Output = Result<(), Error>> + Send { ... } fn delete_permissions<B: Backend>( &self, ctx: &Context<B>, target: impl Into<OverwriteTarget>, reason: Option<&str>, ) -> impl Future<Output = Result<(), Error>> + Send { ... } fn create_webhook<B: Backend>( &self, ctx: &Context<B>, body: &CreateWebhook, reason: Option<&str>, ) -> impl Future<Output = Result<Webhook, Error>> + Send { ... } fn webhooks<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<Collection<WebhookId, Webhook>, Error>> + Send { ... } fn create_invite<B: Backend>( &self, ctx: &Context<B>, body: &CreateChannelInvite, reason: Option<&str>, ) -> impl Future<Output = Result<InviteWithMetadata, Error>> + Send { ... } fn invites<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<Collection<String, InviteWithMetadata>, Error>> + Send { ... } fn threads<'a, B: Backend>( &self, ctx: &'a Context<B>, ) -> ThreadManager<'a, B> { ... } fn thread_members<'a, B: Backend>( &self, ctx: &'a Context<B>, ) -> ThreadMemberManager<'a, B> { ... } fn send_soundboard_sound<B: Backend>( &self, ctx: &Context<B>, body: &SendSoundboardSound, ) -> impl Future<Output = Result<(), Error>> + Send { ... } fn message_collector<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<Arc<MessageCreate>> { ... } fn await_messages<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<Arc<MessageCreate>, All> { ... } fn component_collector<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<ComponentInteraction> { ... } fn await_component<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<ComponentInteraction, First> { ... }
}
Expand description

Actions on a Channel (the model type, which is also the type the cache keeps).

This trait is sealed.

discord.js counterpart: the methods of BaseChannel and its subclasses.

§Examples

client.on(Events::ThreadCreate, |ctx, thread| async move {
    thread.send(&ctx, "Welcome to the thread!").await?;
    Ok(())
});

Provided Methods§

Source

fn messages<'a, B: Backend>(&self, ctx: &'a Context<B>) -> MessageManager<'a, B>

The manager of this channel’s messages.

discord.js counterpart: TextChannel#messages.

Source

fn send<B: Backend>( &self, ctx: &Context<B>, body: impl Into<CreateMessage>, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send

Sends a message to this channel (MessageManager::send).

discord.js counterpart: TextChannel#send.

§Errors

Returns the REST error if the message could not be sent.

Source

fn send_typing<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<(), Error>> + Send

Shows the bot as typing in this channel (ChannelManager::send_typing).

discord.js counterpart: TextChannel#sendTyping.

§Errors

Returns the REST error if the request failed.

Source

fn bulk_delete<B: Backend>( &self, ctx: &Context<B>, message_ids: Vec<MessageId>, reason: Option<&str>, ) -> impl Future<Output = Result<(), Error>> + Send

Deletes 2 to 100 recent messages of this channel (MessageManager::bulk_delete).

discord.js counterpart: TextChannel#bulkDelete.

§Errors

Returns the REST error if the request failed.

Source

fn edit<B: Backend>( &self, ctx: &Context<B>, body: &ModifyGuildChannel, reason: Option<&str>, ) -> impl Future<Output = Result<Arc<Channel>, Error>> + Send

Edits this guild channel (ChannelManager::edit).

discord.js counterpart: GuildChannel#edit.

§Errors

Returns the REST error if the request failed.

Source

fn delete<B: Backend>( &self, ctx: &Context<B>, reason: Option<&str>, ) -> impl Future<Output = Result<Channel, Error>> + Send

Deletes this channel (ChannelManager::delete).

discord.js counterpart: GuildChannel#delete.

§Errors

Returns the REST error if the request failed.

Source

fn set_permissions<B: Backend>( &self, ctx: &Context<B>, target: impl Into<OverwriteTarget>, allow: Permissions, deny: Permissions, reason: Option<&str>, ) -> impl Future<Output = Result<(), Error>> + Send

Sets this channel’s permission overwrite for a role or a member, replacing it (D-235, ChannelManager::set_permissions).

discord.js counterpart: PermissionOverwriteManager#create.

§Errors

Returns the REST error if the request failed.

Source

fn delete_permissions<B: Backend>( &self, ctx: &Context<B>, target: impl Into<OverwriteTarget>, reason: Option<&str>, ) -> impl Future<Output = Result<(), Error>> + Send

Removes this channel’s permission overwrite for a role or a member (ChannelManager::delete_permissions).

discord.js counterpart: PermissionOverwriteManager#delete.

§Errors

Returns the REST error if the request failed.

Source

fn create_webhook<B: Backend>( &self, ctx: &Context<B>, body: &CreateWebhook, reason: Option<&str>, ) -> impl Future<Output = Result<Webhook, Error>> + Send

Creates a webhook in this channel (WebhookManager::create).

discord.js counterpart: TextChannel#createWebhook.

§Errors

Returns the REST error if the request failed.

Source

fn webhooks<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<Collection<WebhookId, Webhook>, Error>> + Send

The webhooks of this channel (WebhookManager::list_channel).

discord.js counterpart: TextChannel#fetchWebhooks.

§Errors

Returns the REST error if the request failed.

Source

fn create_invite<B: Backend>( &self, ctx: &Context<B>, body: &CreateChannelInvite, reason: Option<&str>, ) -> impl Future<Output = Result<InviteWithMetadata, Error>> + Send

Creates an invite to this channel (InviteManager::create).

discord.js counterpart: TextChannel#createInvite.

§Errors

Returns the REST error if the request failed.

Source

fn invites<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<Collection<String, InviteWithMetadata>, Error>> + Send

The invites to this channel (InviteManager::list_channel).

discord.js counterpart: TextChannel#fetchInvites.

§Errors

Returns the REST error if the request failed.

Source

fn threads<'a, B: Backend>(&self, ctx: &'a Context<B>) -> ThreadManager<'a, B>

The manager of this channel’s threads: create, list archived (D-242).

discord.js counterpart: TextChannel#threads.

Source

fn thread_members<'a, B: Backend>( &self, ctx: &'a Context<B>, ) -> ThreadMemberManager<'a, B>

The manager of this thread’s members: add, remove, join, leave (D-242).

discord.js counterpart: ThreadChannel#members.

Source

fn send_soundboard_sound<B: Backend>( &self, ctx: &Context<B>, body: &SendSoundboardSound, ) -> impl Future<Output = Result<(), Error>> + Send

Plays a soundboard sound in this voice channel (ChannelManager::send_soundboard_sound).

discord.js counterpart: VoiceChannel#sendSoundboardSound.

§Errors

Returns the REST error if the request failed.

Source

fn message_collector<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<Arc<MessageCreate>>

A collector of the messages sent in this channel (Context::message_collector).

discord.js counterpart: TextChannel#createMessageCollector.

Source

fn await_messages<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<Arc<MessageCreate>, All>

Collects the messages sent in this channel until the collector ends (Context::await_messages).

discord.js counterpart: TextChannel#awaitMessages.

Source

fn component_collector<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<ComponentInteraction>

A collector of the component interactions on every message of this channel (Context::component_collector).

discord.js counterpart: TextChannel#createMessageComponentCollector.

Source

fn await_component<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<ComponentInteraction, First>

Waits for one component interaction on any message of this channel (Context::await_component).

discord.js counterpart: TextChannel#awaitMessageComponent.

§Errors

CollectorError with the reason if the collector ended first.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ChannelExt for Channel

Implementors§