Skip to main content

UserExt

Trait UserExt 

Source
pub trait UserExt: User {
    // Provided methods
    fn send<B: Backend>(
        &self,
        ctx: &Context<B>,
        body: impl Into<CreateMessage>,
    ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send { ... }
    fn create_dm<B: Backend>(
        &self,
        ctx: &Context<B>,
    ) -> impl Future<Output = Result<Arc<Channel>, Error>> + Send { ... }
}
Expand description

Actions on a user: User or CachedUser.

This trait is sealed.

discord.js counterpart: the methods of User.

§Examples

client.on(Events::GuildMemberAdd, |ctx, join| async move {
    join.user.send(&ctx, "Welcome!").await?;
    Ok(())
});

Provided Methods§

Source

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

Sends a direct message to this user (UserManager::send).

discord.js counterpart: User#send.

§Errors

Returns the REST error if a request failed.

Source

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

The DM channel with this user (UserManager::create_dm).

discord.js counterpart: User#createDM.

§Errors

Returns the REST error if the request failed.

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 UserExt for CachedUser

Source§

impl UserExt for User

Implementors§