user-only-messages

# Ephemeral Replies ('Only You Can See This' Replies)

If you've used a Discord bot, there's a chance that you've encountered a message from one that said "Only you can see this" after you interacted with it (or executed a command). These messages are pretty helpful and can be used in many instances where you'd only like the user that's interacting to see what's going on.

Here's how you can do exactly that!

    #include<dpp/dpp.h>

    intmain(){
    /*Createthebot*/
    dpp::clusterbot("token");

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

    /*Theeventisfiredwhensomeoneissuesyourcommands*/
    bot.on_slashcommand([](constdpp::slashcommand_t&event){
    /*Checkwhichcommandtheyran*/
    if(event.command.get_command_name()=="hello"){
    /*Replytotheuser,butonlyletthemseetheresponse.*/
    event.reply(dpp::message("Hello!Howareyoutoday?").set_flags(dpp::m_ephemeral));
    }
    });

    bot.on_ready([&bot](constdpp::ready_t&event){
    if(dpp::run_once<struct register_bot_commands>()){
    /*CreateandRegisterthecommand*/
    bot.global_command_create(dpp::slashcommand("hello","Hellothere!",bot.me.id));
    }
    });

    bot.start(dpp::st_wait);

    return0;
    }

That's it! If everything went well, it should look like this: