* [Docs] Get docs working on latest docfx version. Removed light-dark-theme as it didn't work with modern docfx, and Material provides the features it provided anyways. Gotta figure out how to get the description generator and "last modified" plugins to work. * [Docs] Get docs working on latest docfx version. Removed light-dark-theme as it didn't work with modern docfx, and Material provides the features it provided anyways. Gotta figure out how to get the description generator and "last modified" plugins to work. * [Docs] Re-add search index extractor. * [Docs] Use material theme and override derived tree style. Also adds a tiny GitHub icon on the navbar. * [Docs] Exclude DebugTools project. * [Docs] Use better method for overriding things. Totally not because DocFX won't allow me to have an override template. * [Docs] Improve styling overrides. * [Docs] Fix links in FAQs and guides. * [Docs] Use new xref service. The old xref service is being deprecated by the end of the year. See https://github.com/dotnet/docfx/issues/8958 * [Docs] Replace (c) with proper copyright symbol. * [Docs] Fix formatting in docfx.json file. Thanks, VSCode. * [Docs] Remove non-working post processors. They don't work, and *personally* I feel like they're unnecessary considering you can check the last modification date in the (linked) GitHub page. I honestly have no idea what the other post processor does and honestly the code doesn't help much either. * [Docs] Fix "in this article" being too thin. Fixes https://github.com/discord-net/Discord.Net/pull/2778#issuecomment-1748812077 * [Docs] Get examples working again. * [Docs] Make properties be separated more clearly. * [Docs] Change docs index to reflect the new nightly MyGet feed. * [Docs] Get docs working on latest docfx version. Removed light-dark-theme as it didn't work with modern docfx, and Material provides the features it provided anyways. Gotta figure out how to get the description generator and "last modified" plugins to work. * [Docs] Get docs working on latest docfx version. Removed light-dark-theme as it didn't work with modern docfx, and Material provides the features it provided anyways. Gotta figure out how to get the description generator and "last modified" plugins to work. * [Docs] Re-add search index extractor. * [Docs] Use material theme and override derived tree style. Also adds a tiny GitHub icon on the navbar. * [Docs] Exclude DebugTools project. * [Docs] Use better method for overriding things. Totally not because DocFX won't allow me to have an override template. * [Docs] Improve styling overrides. * [Docs] Fix links in FAQs and guides. * [Docs] Use new xref service. The old xref service is being deprecated by the end of the year. See https://github.com/dotnet/docfx/issues/8958 * [Docs] Replace (c) with proper copyright symbol. * [Docs] Fix formatting in docfx.json file. Thanks, VSCode. * [Docs] Remove non-working post processors. They don't work, and *personally* I feel like they're unnecessary considering you can check the last modification date in the (linked) GitHub page. I honestly have no idea what the other post processor does and honestly the code doesn't help much either. * [Docs] Fix "in this article" being too thin. Fixes https://github.com/discord-net/Discord.Net/pull/2778#issuecomment-1748812077 * [Docs] Get examples working again. * [Docs] Make properties be separated more clearly. * [Docs] Change docs index to reflect the new nightly MyGet feed. * [Docs] Fix index image not switching when changing themes. Co-Authored-By: exsersewo <25526843+exsersewo@users.noreply.github.com> * add updated description generator postprocessor * update postprocessor * got it working * downgrade postprocessor docfx * [Docs] Add left margin to side navigation links. * remove dup docs cuz `<inheritdoc />` --------- Co-authored-by: exsersewo <25526843+exsersewo@users.noreply.github.com> Co-authored-by: Misha133 <mihagribkov133@gmail.com> Co-authored-by: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com>
2.5 KiB
uid, title
| uid | title |
|---|---|
| Guides.MessageComponents.Intro | Getting Started with Components |
Message Components
Message components are a framework for adding interactive elements to a message your app or bot sends. They're accessible, customizable, and easy to use.
What is a Component
Components are a new parameter you can use when sending messages with your bot. There are currently 2 different types of components you can use: Buttons and Select Menus.
Creating components
Lets create a simple component that has a button. First thing we need is a way to trigger the message, this can be done via commands or simply a ready event. Lets make a command that triggers our button message.
[Command("spawner")]
public async Task Spawn()
{
// Reply with some components
}
We now have our command, but we need to actually send the buttons with the command. To do that, lets look at the ComponentBuilder class:
| Name | Description |
|---|---|
FromMessage |
Creates a new builder from a message. |
FromComponents |
Creates a new builder from the provided list of components. |
WithSelectMenu |
Adds a SelectMenuBuilder to the ComponentBuilder at the specific row. |
WithButton |
Adds a ButtonBuilder to the ComponentBuilder at the specific row. |
Build |
Builds this builder into a MessageComponent used to send your components. |
We see that we can use the WithButton function so lets do that. looking at its parameters it takes:
label- The display text of the button.customId- The custom id of the button, this is whats sent by discord when your button is clicked.style- The discord defined style of the button.emote- An emote to be displayed with the button.url- The url of the button if its a link button.disabled- Whether or not the button is disabled.row- The row the button will occupy.
Since were just making a busic button, we dont have to specify anything else besides the label and custom id.
var builder = new ComponentBuilder()
.WithButton("label", "custom-id");
Lets add this to our command:
[Command("spawner")]
public async Task Spawn()
{
var builder = new ComponentBuilder()
.WithButton("label", "custom-id");
await ReplyAsync("Here is a button!", components: builder.Build());
}
