add basic discord support
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
\page components Using Button Components
|
||||
|
||||
Discord's newest features support sending buttons alongside messages, which when clicked by the user trigger an interaction which is routed by D++ as an `on_button_click` event. To make use of this, use this code as in this example.
|
||||
|
||||
\include{cpp} components.cpp
|
||||
|
||||
When the feature is functioning, the code below will produce buttons on the reply message like in the image below:
|
||||
|
||||
\image html button.png
|
||||
@@ -0,0 +1,9 @@
|
||||
\page components2 Advanced Button Components
|
||||
|
||||
This example demonstrates adding multiple buttons, receiving button clicks, and sending response messages.
|
||||
|
||||
\include{cpp} components2.cpp
|
||||
|
||||
This code will send a different message for correct and incorrect answers.
|
||||
|
||||
\image html button_2.png
|
||||
@@ -0,0 +1,17 @@
|
||||
\page components3 Using Select Menu Components
|
||||
|
||||
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
|
||||
- Allowing users 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
|
||||
@@ -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
|
||||
@@ -0,0 +1,19 @@
|
||||
\page editing_message_after_click Editing The Message From a Button Click
|
||||
|
||||
\note This page expects you to be familiar with Button Clicks and extends from the \ref components page. Please visit the \ref components page if you are not already familiar with Button Clicks.
|
||||
|
||||
Editing messages where you had a button click can be done in a couple ways.
|
||||
|
||||
If you want to edit the message that had the buttons on, instead of doing `event.reply("message");`, you would do `event.reply(dpp::ir_update_message, "message");`, like so:
|
||||
|
||||
\note You are still limited to the default interaction time (3 seconds) this way. Read on if you need more time!
|
||||
|
||||
\include{cpp} editing_message_after_click.cpp
|
||||
|
||||
However, if you're going to take longer than 3 seconds to respond, you need to tell Discord to wait. The usual method is `event.thinking(true);` and then `event.edit_response("I have thought long and hard about my actions.");`, however, `event.thinking()` will create a new response if called from `on_button_click`, meaning you can no longer respond to the original response as you already did a response!
|
||||
|
||||
Instead, you want to do `event.reply(dpp::ir_deferred_channel_message_with_source, "");` to tell Discord that you intend on editing the message that the button click came from, but you need time. The user will be informed that you've processed the button click (as required) via a loading state and then you have 15 minutes to do everything you need. To then edit the message, you need to do `event.edit_response("new message!");`, like so:
|
||||
|
||||
\note If you want to silently acknowledge the button click (no thinking message), replace dpp::ir_deferred_channel_message_with_source with dpp::ir_deferred_update_message. You will still have 15 minutes to make a response.
|
||||
|
||||
\include{cpp} editing_message_after_click2.cpp
|
||||
Reference in New Issue
Block a user