-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (67 loc) · 2.49 KB
/
main.cpp
File metadata and controls
76 lines (67 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <dpp/dpp.h>
#include <csdtlib>
/* Be sure to place your token in the line below.
* Follow steps here to get a token:
* https://dpp.dev/creating-a-bot-application.html
* When you invite the bot, be sure to invite it with the
* scopes 'bot' and 'applications.commands', e.g.
* https://discord.com/oauth2/authorize?client_id=940762342495518720&scope=bot+applications.commands&permissions=139586816064
*/
const std::string BOT_TOKEN = std::getenv("DISCORD_BOT_TOKEN");
int main() {
/* Create bot cluster */
dpp::cluster bot(BOT_TOKEN);
/* Output simple log messages to stdout */
bot.on_log(dpp::utility::cout_logger());
/* Handle slash command with the most recent addition to D++ features, coroutines! */
bot.on_slashcommand([](const dpp::slashcommand_t& event) -> dpp::task<void> {
if (event.command.get_command_name() == "ping") {
co_await event.co_reply("Pong!");
}
else if (event.command.get_command_name() == "embed") {
/* Create an embed */
dpp::embed embed = dpp::embed()
.set_color(dpp::colors::sti_blue)
.set_title("Onboarding Session Reminder!")
/*.set_url("https://dpp.dev/")*/
/*.set_author("PAST", "https://www.perthaerospace.com/", "https://imgur.com/a/NbIlqRu") Can set author at top of post*/
.set_description("New Recruits Onboarding")
/*.set_thumbnail("https://dpp.dev/DPP-Logo.png") Can include image */
.add_field(
"Wednesday 12pm - 2pm",
"Arts Precinct Building.Room"
)
.add_field(
"Onboarding Session One",
"@everyone",
true
)
/*.add_field(
"Inline field title",
"Some value here",
true
) Can include another field*/
/*.set_image("https://dpp.dev/DPP-Logo.png") Can include image*/
.set_footer(
dpp::embed_footer()
.set_text("See you there!")
/* .set_icon("https://imgur.com/a/NbIlqRu")*/
)
.set_timestamp(time(0));
/* Create a message with the content as our new embed. */
dpp::message msg(event.command.channel_id, embed);
/* Reply to the user with the message, containing our embed. */
event.reply(msg);
}
});
bot.on_ready([&bot](const dpp::ready_t& event) {
if (dpp::run_once<struct register_commands>()) {
bot.global_command_create(dpp::slashcommand("ping", "Replies with pong", bot.me.id));
bot.global_command_create(dpp::slashcommand("embed", "Send onboarding embed", bot.me.id));
}
});
/* Start the bot */
bot.start(dpp::st_wait);
return 0;
}