Debian Codegraph @

docpages/example_code/using_emojis2.cpp

raw
1 #include <dpp/dpp.h>
2 #include <dpp/unicode_emoji.h>
3
4 int main() {
5 dpp::cluster bot("Epic Token", dpp::i_default_intents | dpp::i_message_content);
6 /* The second argument is a bitmask of intents - i_message_content is needed to see the messages */
7
8 bot.on_log(dpp::utility::cout_logger());
9
10 /* We'll be using a shocked guy emoji */
11 dpp::emoji shocked("vahuyi", 1179366531856093214);
12 dpp::emoji mad("mad", 1117795317052616704, dpp::e_animated); /* We need this third argument, which is an emoji flag. */
13
14 bot.on_message_create([&bot, shocked, mad](const dpp::message_create_t& event) {
15 if (event.msg.content == "I'm hungry") {
16 /* But if they're hungry */
17 bot.message_add_reaction(event.msg.id, event.msg.channel_id, dpp::unicode_emoji::cut_of_meat);
18 /* Let's send some meat to the message, so they don't starve. They will thank us later. */
19
20 } else if (event.msg.content == "WHAT?") {
21 /* If some unknown content shocked the user */
22 bot.message_add_reaction(event.msg.id, event.msg.channel_id, shocked.format());
23 /* React to their message with a shocked guy */
24
25 } else if (event.msg.content == "I'm unsubscribing") {
26 /* They are angry! We should also be! */
27 bot.message_add_reaction(event.msg.id, event.msg.channel_id, mad.format());
28 /* React to their message with a mad emoji */
29 }
30 });
31
32 /* Start the bot! */
33 bot.start(dpp::st_wait);
34 return 0;
35 }