|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // Created by Memer on 24.08.18.
- // Copyright (c) 2018 Alexander Memer. All rights reserved.
- //
-
- #include <discord.h>
- #include <stdlib.h>
- #include <string.h>
- #include <log.h>
- #include <getopt.h>
-
- 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);
-
- return 0;
- }
|