fn user(ctx: &mut Context, msg: &Message, args: Args) -> CommandResult {
    let guild_id = msg.guild_id.ok_or("Failed to get GuildID from Message.")?;
    // TODO: Find a user via userid if provided
    let member = if msg.mentions.is_empty() {
        if args.is_empty() {
            msg.member(&ctx).ok_or("Could not find member.")?
        } else {
            (*(guild_id
                .to_guild_cached(&ctx)
                .ok_or("Failed to get Guild from GuildId")?
                .read()
                .members_starting_with(args.rest(), false, true)
                .first()
                .ok_or("Could not find member")?))
            .clone()
        }
    } else {
        guild_id.member(
            &ctx,
            msg.mentions
                .first()
                .ok_or("Failed to get user mentioned.")?,
        )?
    };

    let user = member.user.read();
    let roles = member.roles(&ctx).map_or(
        "No role data found for this user in the cache".to_owned(),
        |m| {
            let mut role_id_list = String::new();
            for role in m {
                role_id_list.push_str(format!("<@&{}>\n", role.id.as_u64()).as_ref())
            }
            role_id_list
        },
    );
    let nickname = member.nick.map_or("None".to_owned(), |nick| nick);
    let member_joined = member.joined_at.map_or("Unavailable".to_owned(), |d| {
        d.format("%a, %d %h %Y @ %H:%M:%S").to_string()
    });

    msg.channel_id
        .send_message(&ctx, move |m| {
            m.embed(move |e| {
                e.author(|a| a.name(&user.name));
                e.thumbnail(&user.face());
                e.field("Discriminator", format!("#{:04}", user.discriminator), true);
                e.field("User ID", user.id, true);
                e.field("Nickname", nickname, true);
                e.field("Profile", format!("<@{}>", user.id), true);
                e.field("Joined Server", member_joined, true);
                e.field("Roles", roles, true);
                if user.bot {
                    e.field("Bot Account", user.bot, true);
                }
                e.timestamp(msg.timestamp.to_rfc3339());
                e.footer(|f| {
                    f.text(format!("Requested by {}", msg.author.tag()));
                    f.icon_url(msg.author.face());
                    f
                });
                e
            })
        })
        .map_or_else(|e| Err(CommandError(e.to_string())), |_| Ok(()))
}
/// Shows various information about a user
Shows various information about a user
Shows various information about a user
fn user(ctx: &mut Context, msg: &Message, args: Args) -> CommandResult {
    let guild_id = msg.guild_id.ok_or("Failed to get GuildID from Message.")?;
    // TODO: Find a user via userid if provided
    let member = if msg.mentions.is_empty() {
        if args.is_empty() {
            msg.member(&ctx).ok_or("Could not find member.")?
        } else {
            (*(guild_id
                .to_guild_cached(&ctx)
                .ok_or("Failed to get Guild from GuildId")?
                .read()
                .members_starting_with(args.rest(), false, true)
                .first()
                .ok_or("Could not find member")?))
            .clone()
        }
    } else {
        guild_id.member(
            &ctx,
            msg.mentions
                .first()
                .ok_or("Failed to get user mentioned.")?,
        )?
    };
    let user = member.user.read();
    let roles = member.roles(&ctx).map_or(
        "No role data found for this user in the cache".to_owned(),
        |m| {
            let mut role_id_list = String::new();
            for role in m {
                role_id_list.push_str(format!("<@&{}>\n", role.id.as_u64()).as_ref())
            }
            role_id_list
        },
    );
    let nickname = member.nick.map_or("None".to_owned(), |nick| nick);
    let member_joined = member.joined_at.map_or("Unavailable".to_owned(), |d| {
        d.format("%a, %d %h %Y @ %H:%M:%S").to_string()
    });
    msg.channel_id
        .send_message(&ctx, move |m| {
            m.embed(move |e| {
                e.author(|a| a.name(&user.name));
                e.thumbnail(&user.face());
                e.field("Discriminator", format!("#{:04}", user.discriminator), true);
                e.field("User ID", user.id, true);
                e.field("Nickname", nickname, true);
                e.field("Profile", format!("<@{}>", user.id), true);
                e.field("Joined Server", member_joined, true);
                e.field("Roles", roles, true);
                if user.bot {
                    e.field("Bot Account", user.bot, true);
                }
                e.timestamp(msg.timestamp.to_rfc3339());
                e.footer(|f| {
                    f.text(format!("Requested by {}", msg.author.tag()));
                    f.icon_url(msg.author.face());
                    f
                });
                e
            })
        })
        .map_or_else(|e| Err(CommandError(e.to_string())), |_| Ok(()))
}
fn user ( ctx : & mut Context , msg : & Message , args : Args ) -> CommandResult { let guild_id = msg . guild_id . ok_or ( " " ) ? ; // TODO: Find a user via userid if provided let member = if msg . mentions . is_empty ( ) { if args . is_empty ( ) { msg . member ( & ctx ) . ok_or ( " " ) ? } else { ( * ( guild_id . to_guild_cached ( & ctx ) . ok_or ( " " ) ? . read ( ) . members_starting_with ( args . rest ( ) , false , true ) . first ( ) . ok_or ( " " ) ? ) ) . clone ( ) } } else { guild_id . member ( & ctx , msg . mentions . first ( ) . ok_or ( " " ) ? , ) ? } ; let user = member . user . read ( ) ; let roles = member . roles ( & ctx ) . map_or ( " " . to_owned ( ) , | m | { let mut role_id_list = String :: new ( ) ; for role in m { role_id_list . push_str ( format ! ( " \n " role id as_u64 ( ) ) . as_ref ( ) ) } role_id_list } , ) ; let nickname = member . nick . map_or ( " " . to_owned ( ) , | nick | nick ) ; let member_joined = member . joined_at . map_or ( " " . to_owned ( ) , | d | { d . format ( " " ) . to_string ( ) } ) ; msg . channel_id . send_message ( & ctx , move | m | { m . embed ( move | e | { e . author ( | a | a . name ( & user . name ) ) ; e . thumbnail ( & user . face ( ) ) ; e . field ( " " , format ! ( " " user discriminator ) , true ) ; e . field ( " " , user . id , true ) ; e . field ( " " , nickname , true ) ; e . field ( " " , format ! ( " " user id ) , true ) ; e . field ( " " , member_joined , true ) ; e . field ( " " , roles , true ) ; if user . bot { e . field ( " " , user . bot , true ) ; } e . timestamp ( msg . timestamp . to_rfc3339 ( ) ) ; e . footer ( | f | { f . text ( format ! ( " " msg author tag ( ) ) ) ; f . icon_url ( msg . author . face ( ) ) ; f } ) ; e } ) } ) . map_or_else ( | e | Err ( CommandError ( e . to_string ( ) ) ) , | _ | Ok ( ( ) ) ) }
Shows various information about a user
Shows various information about a user
ctx
&mut Context
msg
&Message
args
Args
ctx
&mut Context
msg
&Message
args
Args