#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <assert.h>
void
print_usage(void)
{
printf("\n\nThis bot demonstrates how easy it is to manipulate guild"
" template endpoints.\n"
"1. Type 'guild-template.get <code>' to get a guild template's "
"information\n"
"2. Type 'guild-template.create' to create a new guild template\n"
"3. Type 'guild-template.sync' to sync the guild template\n"
"\nTYPE ANY KEY TO START BOT\n");
}
void
on_ready(
struct discord *client,
const struct discord_ready *event)
{
"Guild-Bot succesfully connected to Discord as %s#%s!",
event->user->username, event->user->discriminator);
}
void
const struct discord_guild_template *template)
{
const struct discord_message *
event = resp->
keep;
snprintf(text, sizeof(text),
"Here is some information about your guild template:\nName: "
"'%s'\nDescription: '%s'\nCreator Id: %" PRIu64 "\n",
template->name, template->description, template->creator_id);
}
void
{
const struct discord_message *
event = resp->
keep;
snprintf(text, sizeof(text), "Couldn't perform operation: %s",
}
void
on_get_guild_template(
struct discord *client,
const struct discord_message *event)
{
.keep = event,
};
}
void
on_create_guild_template(
struct discord *client,
const struct discord_message *event)
{
.keep = event,
};
.name = "New server template!",
.description = "This is a new server template created with Concord!"
};
}
void
on_sync_guild_template(
struct discord *client,
const struct discord_message *event)
{
.keep = event,
};
}
int
main(int argc, char *argv[])
{
const char *config_file;
if (argc > 1)
config_file = argv[1];
else
config_file = "../config.json";
assert(NULL != client && "Couldn't initialize client");
print_usage();
fgetc(stdin);
}
Public functions and datatypes.
CCORDcode discord_create_message(struct discord *client, u64snowflake channel_id, struct discord_create_message *params, struct discord_ret_message *ret)
Post a message to a guild text or DM channel.
CCORDcode discord_sync_guild_template(struct discord *client, u64snowflake guild_id, const char template_code[], struct discord_ret_guild_template *ret)
Syncs the template to the guild's current state.
CCORDcode discord_get_guild_template(struct discord *client, const char template_code[], struct discord_ret_guild_template *ret)
Get a guild template for the given code.
CCORDcode discord_create_guild_template(struct discord *client, u64snowflake guild_id, struct discord_create_guild_template *params, struct discord_ret_guild_template *ret)
Creates a template for the guild.
void discord_cleanup(struct discord *client)
Free a Discord Client handle.
CCORDcode discord_run(struct discord *client)
Start a connection to the Discord Gateway.
struct discord * discord_from_json(const char config_file[])
Creates a Discord Client handle from a config.json file.
#define DISCORD_MAX_MESSAGE_LEN
Definition: discord.h:71
const char * discord_strerror(CCORDcode code, struct discord *client)
Return the meaning of CCORDcode.
void discord_set_prefix(struct discord *client, const char prefix[])
Set a mandatory prefix before commands.
void discord_set_on_ready(struct discord *client, void(*callback)(struct discord *client, const struct discord_ready *event))
Triggers when the client session is ready.
void discord_set_on_command(struct discord *client, const char *command, void(*callback)(struct discord *client, const struct discord_message *event))
Set command/callback pair.
#define logmod_log
Alias to logmod_nlog for C89 compatibility.
Definition: logmod.h:487
The response for the completed request.
Definition: discord-response.h:12
const void * keep
Definition: discord-response.h:16
CCORDcode code
Definition: discord-response.h:18
Request's return context.
Definition: discord-response.h:131
void(* fail)(struct discord *client, struct discord_response *resp)
Definition: discord-response.h:131
void(* done)(struct discord *client, struct discord_response *resp, const struct discord_guild_template *ret)
Definition: discord-response.h:131
The Discord client handler.
Definition: discord-internal.h:1206