using-cache

# Using Cache

Sometimes you may need information that is not directly available in the event callback object.

To handle this DPP maintains a cache of commonly used data for you.

As of August 30th, 2022, Discord made Guild Members a privileged intent. You must have GUILD_MEMBERS intent enabled for your app from discord developers portal to be able to look for members in cache.

Below is an example showing how to get a user from the cache

    #include<dpp/dpp.h>

    intmain(){
    /*Createbot*/
    dpp::clusterbot("token",dpp::i_default_intents|dpp::i_guild_members);

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

    /*Thiseventisfiredwhensomeoneremovestheirreactionfromamessage*/
    bot.on_message_reaction_remove([&bot](constdpp::message_reaction_remove_t&event){
    /*Findtheuserinthecacheusinghisdiscordid*/
    dpp::user*reacting_user=dpp::find_user(event.reacting_user_id);

    /*Ifusernotfoundincache,logandreturn*/
    if(!reacting_user){
    bot.log(dpp::ll_info,"Userwiththeid"+std::to_string(event.reacting_user_id)+"wasnotfound.");
    return;
    }

    bot.log(dpp::ll_info,reacting_user->format_username()+"removedhisreaction.");
    });

    bot.start(dpp::st_wait);

    return0;
    }

DPP caches more than just users, which you can get using the below-mentioned functions:

- `dpp::find_role()`

- `dpp::find_channel()`

- `dpp::find_emoji()`

- `dpp::find_guild()`

- `dpp::find_guild_member()`