static void
on_message(
struct discord *client,
const struct discord_message *message)
{
if (message->author->bot) return;
const struct discord_guild *guild =
if (guild) {
printf("message received in guild '%s'\n", guild->name);
}
const struct discord_message *cached_message =
message->id);
if (cached_message) {
.content = cached_message->content,
},
NULL);
}
}
int
main(int argc, char *argv[])
{
const char *const config_file = argc > 1 ? argv[1] : "../config.json";
}
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.
const struct discord_message * discord_cache_get_channel_message(struct discord *client, u64snowflake channel_id, u64snowflake message_id)
Get a message from cache, only if locally available in RAM.
void discord_cache_enable(struct discord *client, enum discord_cache_options options)
const struct discord_guild * discord_cache_get_guild(struct discord *client, u64snowflake guild_id)
Get a guild from cache, only if locally available in RAM.
@ DISCORD_CACHE_GUILDS
Definition: discord-cache.h:17
@ DISCORD_CACHE_MESSAGES
Definition: discord-cache.h:16
void discord_cleanup(struct discord *client)
Free a Discord Client handle.
CCORDcode discord_run(struct discord *client)
Start a connection to the Discord Gateway.
void discord_unclaim(struct discord *client, const void *data)
Unclaim ownership of a resource provided by Concord.
struct discord * discord_from_json(const char config_file[])
Creates a Discord Client handle from a config.json file.
void discord_add_intents(struct discord *client, uint64_t code)
Subscribe to Discord Events.
void discord_set_on_message_create(struct discord *client, void(*callback)(struct discord *client, const struct discord_message *event))
Triggers when a message is created.
The Discord client handler.
Definition: discord-internal.h:1206