#ActionRow not working

1 messages · Page 1 of 1 (latest)

flat wolf
#

This is my code:
https://hst.sh/ixuxatecit.csharp
But when I try to run it:

[2023-09-06 13:06:16 +03:00] [104 /EventHandler] [Error] Event handler exception for event COMPONENT_INTERACTED thrown from System.Threading.Tasks.Task ButtonPressResponse(DSharpPlus.DiscordClient, DSharpPlus.EventArgs.ComponentInteractionCreateEventArgs) (defined in DiscordBot.Program)
DSharpPlus.Exceptions.BadRequestException: Bad request: 400
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at DSharpPlus.Net.DiscordApiClient.<CreateInteractionResponseAsync>d__174.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at DiscordBot.Program.<ButtonPressResponse>d__9.MoveNext() in C:\Users\Doggo\source\repos\DiscordBot\DiscordBot\Program.cs:line 228
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DSharpPlus.AsyncEvents.AsyncEvent`2.<>c__DisplayClass7_0.<<InvokeAsync>b__0>d.MoveNext()
honest wigeonBOT
#
Automated suggestion: How to find a solution to a `BadRequestException`

It's true that the BadRequestException doesn't provide that much information to the console. To get more info about what you did wrong, catch the BadRequestException yourself, and check the .JsonMessage and the .Errors properties.

flat wolf
#

what does this mean

half fjord
#

no overload of AddComponents accepts a single action row, either pass the components for the row directly (this will construct a row per call):

.AddComponents(SpinButton1, EndButton)
.AddComponents(CreditsDropdown1)

or pass an enumerable of action rows

.AddComponents(new[]
{
  new DiscordActionRowComponent(...),
})
.AddComponents(CreditsDropdown1)
half fjord
# flat wolf

the error message here essentially tells you that you put an action row inside an action row (which code your implicitly does due to what the selected overload does), which is invalid