Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Added emoji page #1019

Merged
merged 14 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions docpages/example_code/using_emoji.cpp
Henonicks marked this conversation as resolved.
Show resolved Hide resolved
Henonicks marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <dpp/dpp.h>
#include <dpp/unicode_emoji.h>

int main() {
dpp::cluster bot("Epic Token", dpp::i_default_intents | dpp::i_message_content);
/* The second argument is a bitmask of intents - i_message_content is needed to see the messages */

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

/* We'll be using a shocked guy emoji */
dpp::emoji shocked("vahuyi", 1179366531856093214);

bot.on_message_create([&bot, shocked](const dpp::message_create_t& event) {
if (event.msg.content == "WHAT?") {
/* If some unknown content shocks the user */

bot.message_add_reaction(event.msg.id, event.msg.channel_id, shocked.format());
/* React to their message with a shocked guy */
} else if (event.msg.content == "I'm hungry") {
/* But if they're hungry */

bot.message_add_reaction(event.msg.id, event.msg.channel_id, dpp::unicode_emoji::cut_of_meat);
/* Let's send some meat to the message, so they don't starve. They will thank us later. */
Henonicks marked this conversation as resolved.
Show resolved Hide resolved
}
});

bot.on_slashcommand([shocked](const dpp::slashcommand_t& event) {
if (event.command.get_command_name() == "send-emoji") {

/* Here we send our very informative message: two emojis next to each other.
* We also have to use mention instead of format. */
event.reply(shocked.get_mention() + dpp::unicode_emoji::cut_of_meat);
}
});

bot.on_ready([&bot](const dpp::ready_t& event) {
if (dpp::run_once<struct register_bot_commands>()) {
dpp::slashcommand send("send-emoji", "Send the emoji", bot.me.id);
bot.global_bulk_command_create({ send });
}
});

/* Start the bot! */
bot.start(dpp::st_wait);
return 0;
}
1 change: 1 addition & 0 deletions docpages/example_programs/misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ This section lists examples that do not fit neatly into any of the categories ab
* \subpage cpp-eval-command-discord
* \subpage checking-member-permissions
* \subpage setting_status
* \subpage using-emoji
9 changes: 9 additions & 0 deletions docpages/example_programs/misc/using-emoji.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\page using-emoji Using Emoji

Need your bot to use an emoji? Then the `dpp::emoji` class is just for you. It can store either a custom or a unicode emoji's name and ID. To use one in a message or when reacting to one, you use its mention. In select menus, it's the emoji object itself. Here's how to use them:
Jaskowicz1 marked this conversation as resolved.
Show resolved Hide resolved

\include{cpp} using_emoji.cpp

Now, our bot will react to our messages!

\image html using_emoji.png
Binary file added docpages/images/using_emoji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.