resolved-objects

# Using Resolved Objects

If your slash command accepts options like user, channel, or role you can get their value, as specified by the user in the command, from parameters. Though parameter gives you only the snowflake id of the passed value.

If you need object of that snowflake, you can get that from the resolved set using its snowflake id.

Below is an example showing how to get a member, passed in command options, using resolved set.

    #include<dpp/dpp.h>

    intmain(){
    dpp::clusterbot("token");

    bot.on_log(dpp::utility::cout_logger());

    /*Theeventisfiredwhensomeoneissuesyourcommands*/
    bot.on_slashcommand([&bot](constdpp::slashcommand_t&event){
    /*Checkwhichcommandtheyran*/
    if(event.command.get_command_name()=="addrole"){
    /*Fetchaparametervaluefromthecommandoptions*/
    dpp::snowflakeuser_id=std::get<dpp::snowflake>(event.get_parameter("user"));
    dpp::snowflakerole_id=std::get<dpp::snowflake>(event.get_parameter("role"));

    /*Getmemberobjectfromresolvedlist*/
    dpp::guild_memberresolved_member=event.command.get_resolved_member(user_id);

    resolved_member.add_role(role_id);
    bot.guild_edit_member(resolved_member);

    event.reply("Addedrole");
    }
    });

    /*Attachon_readyevent*/
    bot.on_ready([&bot](constdpp::ready_t&event){
    if(dpp::run_once<struct register_bot_commands>()){
    dpp::slashcommandadd_role("addrole","Giveuserarole",bot.me.id);

    /*Adduserandroletypecommandoptionstotheslashcommand*/
    add_role.add_option(dpp::command_option(dpp::co_user,"user","Usertogiveroleto",true));
    add_role.add_option(dpp::command_option(dpp::co_role,"role","Roletogive",true));

    bot.global_command_create(add_role);
    }
    });

    /*Startbot*/
    bot.start(dpp::st_wait);

    return0;
    }