pub async fn init(ctx: &Context, user: &User, emb: CreateEmbed) -> ConvResult {
        let lock = {
            let data_read = ctx.data.read().await;
            data_read.get::<ConversationLock>().unwrap().clone()
        };

        if !lock.insert(user.id) {
            return Err(ConversationError::ConversationLocked);
        }

        // Check if we can open a dm channel
        let chan = match user.create_dm_channel(ctx).await {
            Ok(c) => c,
            Err(_) => {
                lock.remove(&user.id);
                return Err(ConversationError::NoDmChannel);
            }
        };

        // Send initial message to channel
        let msg = match chan.send_message(ctx, |m| m.set_embed(emb)).await {
            Ok(m) => m,
            Err(_) => {
                lock.remove(&user.id);
                return Err(ConversationError::DmBlocked);
            }
        };

        Ok(Conversation {
            lock,
            user: user.clone(),
            chan,
            msg,
        })
    }
// Same as start but instead sends an embed as initial message
Same as start but instead sends an embed as initial message
Same as start but instead sends an embed as initial message
pub async fn init(ctx: &Context, user: &User, emb: CreateEmbed) -> ConvResult {
        let lock = {
            let data_read = ctx.data.read().await;
            data_read.get::<ConversationLock>().unwrap().clone()
        };
        if !lock.insert(user.id) {
            return Err(ConversationError::ConversationLocked);
        }
        // Check if we can open a dm channel
        let chan = match user.create_dm_channel(ctx).await {
            Ok(c) => c,
            Err(_) => {
                lock.remove(&user.id);
                return Err(ConversationError::NoDmChannel);
            }
        };
        // Send initial message to channel
        let msg = match chan.send_message(ctx, |m| m.set_embed(emb)).await {
            Ok(m) => m,
            Err(_) => {
                lock.remove(&user.id);
                return Err(ConversationError::DmBlocked);
            }
        };
        Ok(Conversation {
            lock,
            user: user.clone(),
            chan,
            msg,
        })
    }
pub async fn init ( ctx : & Context , user : & User , emb : CreateEmbed ) -> ConvResult { let lock = { let data_read = ctx . data . read ( ) . await ; data_read . get :: < ConversationLock > ( ) . unwrap ( ) . clone ( ) } ; if ! lock . insert ( user . id ) { return Err ( ConversationError :: ConversationLocked ) ; } // Check if we can open a dm channel let chan = match user . create_dm_channel ( ctx ) . await { Ok ( c ) => c , Err ( _ ) => { lock . remove ( & user . id ) ; return Err ( ConversationError :: NoDmChannel ) ; } } ; // Send initial message to channel let msg = match chan . send_message ( ctx , | m | m . set_embed ( emb ) ) . await { Ok ( m ) => m , Err ( _ ) => { lock . remove ( & user . id ) ; return Err ( ConversationError :: DmBlocked ) ; } } ; Ok ( Conversation { lock , user : user . clone ( ) , chan , msg , } ) }
Same as start but instead sends an embed as initial message
Same as start but instead sends an embed as initial message
ctx
&Context
user
&User
emb
CreateEmbed