#bad request when using row component and button

1 messages · Page 1 of 1 (latest)

warm crow
#

Hello, i try to send a message with one row component, and inside this row a button, but i'm getting "bad request".

Discord response is:
{
"components": {
"0": {
"components": {
"0": {
"_errors": [
{
"code": "UNION_TYPE_CHOICES",
"message": "Value of field "type" must be one of (2, 3, 4, 5, 6, 7, 8)."
}
]
}
}
}
}
}

But a button is type 2, so i don't understand !

Can someone help me please ?

rancid swallowBOT
#
Automated suggestion: How to diagnose `BadRequestException`s

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.

cunning tulip
#

Can you share the code this is happening in

warm crow
#

And i showed you the variable on the previous screen that the method GetComponents return

sullen raft
#

don't manually construct action rows

warm crow
#

How should i construct then ?

sullen raft
#

not 😛

#

the message builder handles them for you

cunning tulip
#

AddComponents makes a row for the components you pass

warm crow
#

ok i got it

#

So if i've 3 rows, i should call AddComponents method 3 times

sullen raft
#

yes

warm crow
#

Working now, thank you