pub fn send_post(ctx: &mut Context, msg: &Message, post: &Post) -> CommandResult {
    use schema::messages::dsl::*;

    let sent_msg = msg.channel_id.send_message(&ctx.http, |m| {
        m.embed(|e| {
            e.title(&post.title);
            e.author(|a| {
                a.name(&post.author);
                a.url(post.author_url())
            });
            e.image(&post.image);
            e.url(post.post_url());
            e.footer(|f| f.text(format!("{} upvotes", post.ups)))
        })
    })?;

    let mut client_data = ctx.data.write();
    let appdata = client_data.get_mut::<AppData>().unwrap();
    let conn = appdata.db_pool.get().unwrap();

    diesel::insert_into(messages)
        .values(&models::Message::new(&sent_msg, msg))
        .execute(&conn)
        .expect("failed saving message");

    sent_msg.react(&ctx, ReactionType::Unicode("\u{274C}".to_string()))?;

    Ok(())
}
// helper method to send a post on discord
helper method to send a post on discord
helper method to send a post on discord
pub fn send_post(ctx: &mut Context, msg: &Message, post: &Post) -> CommandResult {
    use schema::messages::dsl::*;
    let sent_msg = msg.channel_id.send_message(&ctx.http, |m| {
        m.embed(|e| {
            e.title(&post.title);
            e.author(|a| {
                a.name(&post.author);
                a.url(post.author_url())
            });
            e.image(&post.image);
            e.url(post.post_url());
            e.footer(|f| f.text(format!("{} upvotes", post.ups)))
        })
    })?;
    let mut client_data = ctx.data.write();
    let appdata = client_data.get_mut::<AppData>().unwrap();
    let conn = appdata.db_pool.get().unwrap();
    diesel::insert_into(messages)
        .values(&models::Message::new(&sent_msg, msg))
        .execute(&conn)
        .expect("failed saving message");
    sent_msg.react(&ctx, ReactionType::Unicode("\u{274C}".to_string()))?;
    Ok(())
}
pub fn send_post ( ctx : & mut Context , msg : & Message , post : & Post ) -> CommandResult { use schema :: messages :: dsl :: * ; let sent_msg = msg . channel_id . send_message ( & ctx . http , | m | { m . embed ( | e | { e . title ( & post . title ) ; e . author ( | a | { a . name ( & post . author ) ; a . url ( post . author_url ( ) ) } ) ; e . image ( & post . image ) ; e . url ( post . post_url ( ) ) ; e . footer ( | f | f . text ( format ! ( " " post ups ) ) ) } ) } ) ? ; let mut client_data = ctx . data . write ( ) ; let appdata = client_data . get_mut :: < AppData > ( ) . unwrap ( ) ; let conn = appdata . db_pool . get ( ) . unwrap ( ) ; diesel :: insert_into ( messages ) . values ( & models :: Message :: new ( & sent_msg , msg ) ) . execute ( & conn ) . expect ( " " ) ; sent_msg . react ( & ctx , ReactionType :: Unicode ( " \u{274C} " . to_string ( ) ) ) ? ; Ok ( ( ) ) }
helper method to send a post on discord
helper method to send a post on discord
ctx
&mut Context
msg
&Message
post
&Post