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>
This commit is contained in:
31
docs/guides/components_v2/samples/interactions.cs
Normal file
31
docs/guides/components_v2/samples/interactions.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user