mirror of
https://github.com/HappyTanuki/BumbleCee.git
synced 2025-12-18 21:23:29 +00:00
스킵 구현
This commit is contained in:
35
DPP-master/docpages/example_code/making_threads1.cpp
Normal file
35
DPP-master/docpages/example_code/making_threads1.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <dpp/dpp.h>
|
||||
|
||||
int main() {
|
||||
/* Create the bot */
|
||||
dpp::cluster bot("token");
|
||||
|
||||
bot.on_log(dpp::utility::cout_logger());
|
||||
|
||||
/* The event is fired when the bot detects a message in any server and any channel it has access to. */
|
||||
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
|
||||
/* Check which command they ran */
|
||||
if (event.command.get_command_name() == "create-thread") {
|
||||
/* Here we create a thread in the current channel. It will expire after 60 minutes of inactivity. We'll also allow other mods to join, and we won't add a slowdown timer. */
|
||||
bot.thread_create("Cool thread!", event.command.channel_id, 60, dpp::channel_type::CHANNEL_PUBLIC_THREAD, true, 0, [event](const dpp::confirmation_callback_t& callback) {
|
||||
if (callback.is_error()) {
|
||||
event.reply("Failed to create a thread!");
|
||||
return;
|
||||
}
|
||||
|
||||
event.reply("Created a thread for you!");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
bot.on_ready([&bot](const dpp::ready_t& event) {
|
||||
if (dpp::run_once<struct register_bot_commands>()) {
|
||||
/* Create and register the command */
|
||||
bot.global_command_create(dpp::slashcommand("create-thread", "Create a thread!", bot.me.id));
|
||||
}
|
||||
});
|
||||
|
||||
bot.start(dpp::st_wait);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user