Files
Adriaan Waem cf66ab4520 Docs/components v2 :wires: (#3162)
* new pages :3

* fimished intro page

* fimished interaction page

* remove unused shit

* I think we are done lmao

* I lied, fixed some small mistakes

* Update docs/guides/components_v2/interaction.md

Co-authored-by: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com>

* misha quality assurance :3 + breakings pages

* Apply suggestions from code review

Co-authored-by: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com>

* component types guide expanded

* :3

* Apply suggestions from code review

Co-authored-by: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com>

---------

Co-authored-by: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com>
2025-07-18 22:14:24 +03:00

32 lines
1.1 KiB
C#

private async Task ClientOnInteractionCreatedAsync(SocketInteraction arg)
{
switch (arg)
{
case SocketMessageComponent component:
switch (component.Data.CustomId)
{
// Non dynamic cases ...
default:
var customId = component.Data.CustomId;
var lastPartStartIndex = customId.LastIndexOf('-');
if (lastPartStartIndex == -1)
return;
if (customId[..lastPartStartIndex] == RecipesLookInsideButton) // "recipes-show-me-button"
await component.UpdateAsync(m => m.Components = BuildComponentUnsafe(_recipes.First(r => r.RecipeId == int.Parse(customId[(lastPartStartIndex + 1)..]))).Build()); // _recipes is a list of Recipe objects ; int.Parse({recipe.RecipeId}) (in this case it is 1)
break;
}
break;
case SocketModal modal:
// Interaction came from a modal
break;
default:
return;
}
}