Create Auto Moderation Rule field body has incorrect key name
zeylahellyer opened this issue · 0 comments
zeylahellyer commented
Copied from a report in our Discord: https://discord.com/channels/745809834183753828/1068378089345777725
Messing around with auto mod stuff and getting an error when trying to create a rule.
Error: Response error: status code 400, error: {"code": 50035, "errors": {"actions": {"0": {"type": {"_errors": [{"code": "AUTO_MODERATION_ACTION_TYPE_DISALLOWED", "message": "Action type 0 is not permitted"}]}}}}, "message": "Invalid Form Body"}
Code: (from the example for client.create_automoderation_rule
)
client
.create_auto_moderation_rule(guild_id, "no darns", AutoModerationEventType::MessageSend)
.action_block_message()
.enabled(true)
.with_keyword(&["darn"])
.await?;
Used TryIntoRequest
to get the body:
{
"actions": [
{
"kind": 1,
"metadata": {
"channel_id": null,
"duration_seconds": null
}
},
{
"kind": 2,
"metadata": {
"channel_id": "...",
"duration_seconds": null
}
}
],
"enabled": false,
"event_type": 1,
"exempt_channels": null,
"exempt_roles": null,
"name": "no darns",
"trigger_metadata": null,
"trigger_type": null
}
Haven't locally tried to fix it but I think it's because kind isn't being serialized as "type". See https://github.com/twilight-rs/twilight/blob/main/twilight-http/src/request/guild/auto_moderation/create_auto_moderation_rule.rs#L28 & https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-auto-moderation-action-structure