-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:brainboxdotcc/DPP
- Loading branch information
Showing
11 changed files
with
212 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <dpp/dpp.h> | ||
|
||
int main() { | ||
dpp::cluster bot("token"); | ||
|
||
bot.on_log(dpp::utility::cout_logger()); | ||
|
||
/* The event is fired when someone issues your commands */ | ||
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) { | ||
/* Check which command they ran */ | ||
if (event.command.get_command_name() == "select") { | ||
/* Create a message */ | ||
dpp::message msg(event.command.channel_id, "This text has a select menu!"); | ||
|
||
/* Add an action row, and a select menu within the action row. | ||
* | ||
* By default, max values is 1, meaning people can only pick 1 option. | ||
* We're changing this to two, so people can select multiple options! | ||
* We'll also set the min_values to 2 so people have to pick another value! | ||
*/ | ||
msg.add_component( | ||
dpp::component().add_component( | ||
dpp::component() | ||
.set_type(dpp::cot_role_selectmenu) | ||
.set_min_values(2) | ||
.set_max_values(2) | ||
.set_id("myselectid") | ||
) | ||
); | ||
|
||
/* Reply to the user with our message. */ | ||
event.reply(msg); | ||
} | ||
}); | ||
|
||
bot.on_ready([&bot](const dpp::ready_t& event) { | ||
if (dpp::run_once<struct register_bot_commands>()) { | ||
/* Create and register a command when the bot is ready */ | ||
bot.global_command_create(dpp::slashcommand("select", "Select something at random!", bot.me.id)); | ||
} | ||
}); | ||
|
||
bot.start(dpp::st_wait); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <dpp/dpp.h> | ||
#include <dpp/unicode_emoji.h> | ||
|
||
int main() { | ||
dpp::cluster bot("token"); | ||
|
||
bot.on_log(dpp::utility::cout_logger()); | ||
|
||
/* The event is fired when someone issues your commands */ | ||
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) { | ||
/* Check which command they ran */ | ||
if (event.command.get_command_name() == "select") { | ||
/* Create a message */ | ||
dpp::message msg(event.command.channel_id, "This text has a select menu!"); | ||
|
||
/* Add an action row, and a select menu within the action row. | ||
* | ||
* Your default values are limited to max_values, | ||
* meaning you can't add more default values than the allowed max values. | ||
*/ | ||
msg.add_component( | ||
dpp::component().add_component( | ||
dpp::component() | ||
.set_type(dpp::cot_role_selectmenu) | ||
.set_min_values(2) | ||
.set_max_values(2) | ||
.add_default_value(dpp::snowflake{667756886443163648}, dpp::cdt_role) | ||
.set_id("myselectid") | ||
) | ||
); | ||
|
||
/* Reply to the user with our message. */ | ||
event.reply(msg); | ||
} | ||
}); | ||
|
||
bot.on_ready([&bot](const dpp::ready_t& event) { | ||
if (dpp::run_once<struct register_bot_commands>()) { | ||
/* Create and register a command when the bot is ready */ | ||
bot.global_command_create(dpp::slashcommand("select", "Select something at random!", bot.me.id)); | ||
} | ||
}); | ||
|
||
bot.start(dpp::st_wait); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
docpages/example_programs/interactions_and_components/components/components3.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
\page components3 Using select menu components | ||
|
||
This example demonstrates creating a select menu, receiving select menu clicks and sending a response message. | ||
This tutorial will cover creating two types of select menus: | ||
- A generic select menu with just text | ||
- An auto-populated role select menu. | ||
|
||
This first example demonstrates creating a select menu, receiving select menu clicks, and sending a response message. | ||
|
||
\include{cpp} components3.cpp | ||
|
||
This second example demonstrates creating a role select menu that is auto-populated by discord, and allowing people to select two options! | ||
|
||
\note This type of select menu, along with other types (these types being: user, role, mentionable, and channel), always auto-fill. You never need to define the data in these types of select menus. All select menu types allow you to select multiple options. | ||
|
||
\include{cpp} components3_rolemenu.cpp |
13 changes: 13 additions & 0 deletions
13
...example_programs/interactions_and_components/components/default_select_value.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
\page default_select_value Setting default values on select menus. | ||
|
||
This tutorial will cover how to set the default value for a select menu (that isn't a text select menu)! | ||
|
||
\note **This only works for the following types of select menus: user, role, mentionable, and channel.** The default type of a select menu (as shown in \ref components3 "this page") does not work for this, as that supports a "placeholder". | ||
|
||
\include{cpp} default_select_value.cpp | ||
|
||
If all went well, you should have something like this! | ||
|
||
\image html default_select_value.png | ||
|
||
\image html default_select_value_2.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters