// // Created by Memer on 24.08.18. // Copyright (c) 2018 Alexander Memer. All rights reserved. // #include #include #include #include #include int main(int argc, char **argv) { struct ld_context_info info; info.log_level = 0; while (1) { int c; static struct option long_options[] = { {"bot-token", required_argument, 0, 't'}, {"help", no_argument, 0, 'h'}, {"log-level", required_argument, 0, 'l'}, {0, 0, 0, 0} }; int option_index = 0; c = getopt_long(argc, argv, "t:hl:", long_options, &option_index); if (c == -1) { break; } switch (c) { case 'h': printf("%s: [-t bot_token]\n"); return 0; case 't': info.bot_token = strdup(optarg); break; case 'l': info.log_level = atoi(optarg); break; default: abort(); } } if (!info.bot_token) { log_fatal("no bot token specified"); return -1; } struct ld_context *ctx; ctx = ld_create_context(&info); if (ctx == NULL) { fprintf(stderr, "Failed to create libdiscord context"); return -1; } /* printf("%s\n", ld_get_gateway(ctx)); struct ld_gateway_bot_resp *r = ld_get_gateway_bot(ctx); if (!r) { printf("Error (%d): %s", ctx->last_rest_status->what, ctx->last_rest_status->text); return -1; } printf("%s:%d\n", r->url, r->shards); free(r); int a = ld_create_message(ctx, "444130990252752898", "test"); if (a) { return -1; } */ guild_channel_t channel; ld_get_channel(ctx, "444130990252752898", &channel); log_trace(channel.guild_id); struct ld_modify_channel_obj *m = malloc(sizeof(struct ld_modify_channel_obj)); memset(m, 0, sizeof(struct ld_modify_channel_obj)); m->name = "основной2"; m->user_limit = -1; m->bitrate = -1; m->nsfw = -1; m->position = -1; m->permission_overwrites = calloc(1, sizeof(overwrite_t)); m->overwrites_size = 1; m->permission_overwrites[0].id = "472393766989201408"; m->permission_overwrites[0].type = "member"; m->permission_overwrites[0].deny = 0; m->permission_overwrites[0].allow = 2048; guild_channel_t c; ld_modify_channel_result(ctx, "444130990252752898", m, &c); free(m); ld_delete_channel(ctx, "482874514124832779"); return 0; }