refactor(bot-components): change JSON string to a components array
#include "cee-utils.h"
char JSON_STRING[] = \
-"{\n"
-" \"content\": \"Mason is looking for new arena partners. What classes do you play?\",\n"
-" \"components\": [\n"
+"[\n"
" {\n"
" \"type\": 1,\n"
" \"components\": [\n"
@@ -52,7 +50,6 @@ char JSON_STRING[] = \
" ]\n"
" }\n"
"]\n"
-"}\n"
;
@@ -68,16 +65,16 @@ void on_from_json_init(
{
if (msg->author->bot) return;
- struct discord_message *loaded_msg=NULL;
- discord_message_from_json(JSON_STRING, sizeof(JSON_STRING), &loaded_msg);
+ NTL_T(struct discord_component) components=NULL;
+ discord_component_list_from_json(JSON_STRING, sizeof(JSON_STRING), &components);
struct discord_create_message_params params = {
- .content = loaded_msg->content,
- .components = loaded_msg->components
+ .content = "Mason is looking for new arena partners. What classes do you play?",
+ .components = components
};
discord_create_message(client, msg->channel_id, &params, NULL);
- discord_message_free(loaded_msg);
+ discord_component_list_free(components);
}
void on_designated_init(
