#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <limits.h>
#include <string.h>
#include <assert.h>
void
print_usage(void)
{
printf("\n\nThis bot demonstrates how easy it is to log"
" for certain events.\n"
"1. Type '!last_channel' to check the most recent channel created "
"by you\n"
"\tsee: "
"https://discord.com/developers/docs/resources/"
"audit-log#audit-log-entry-object-audit-log-events\n"
"\nTYPE ANY KEY TO START BOT\n");
}
void
{
log_info(
"Audit-Log-Bot succesfully connected to Discord as %s#%s!",
}
void
log_on_guild_member_add(
struct discord *client,
{
}
void
log_on_guild_member_update(
struct discord *client,
{
char nick[128] = "";
snprintf(nick,
sizeof(nick),
" (%s)", event->
nick);
}
void
log_on_guild_member_remove(
struct discord *client,
{
}
void
{
log_warn(
"No audit log entries found!");
return;
}
char text[1028];
snprintf(text, sizeof(text), "<@!%" PRIu64 "> has created <#%" PRIu64 ">!",
}
void
{
(void)resp;
}
void
on_audit_channel_create(
struct discord *client,
{
.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);
}
CCORDcode ccord_global_init()
Initialize global shared-resources not API-specific.
void ccord_global_cleanup()
Cleanup global shared-resources.
Public functions and datatypes.
@ DISCORD_AUDIT_LOG_CHANNEL_CREATE
Definition: audit_log.h:24
const char * discord_strerror(CCORDcode code, struct discord *client)
Return the meaning of CCORDcode.
CCORDcode discord_get_guild_audit_log(struct discord *client, u64snowflake guild_id, struct discord_get_guild_audit_log *params, struct discord_ret_audit_log *ret)
Get audit log for a given guild.
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.
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_config_init(const char config_file[])
Create a Discord Client handle by a config.json file.
void discord_add_intents(struct discord *client, uint64_t code)
Subscribe to Discord Events.
void discord_set_on_guild_member_update(struct discord *client, void(*callback)(struct discord *client, const struct discord_guild_member_update *event))
Triggers when a guild member is updated.
void discord_set_on_guild_member_remove(struct discord *client, void(*callback)(struct discord *client, const struct discord_guild_member_remove *event))
Triggers when a guild member is removed.
void discord_set_on_guild_member_add(struct discord *client, void(*callback)(struct discord *client, const struct discord_guild_member *event))
Triggers when a guild member is added.
void discord_set_on_command(struct discord *client, char *command, void(*callback)(struct discord *client, const struct discord_message *event))
Set command/callback pair.
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.
#define log_warn(...)
Definition: log.h:53
#define log_error(...)
Definition: log.h:54
#define log_info(...)
Definition: log.h:52
struct discord_audit_log_entry * array
Definition: audit_log.h:126
int size
Definition: audit_log.h:125
Definition: audit_log.h:103
u64snowflake target_id
Definition: audit_log.h:105
u64snowflake user_id
Definition: audit_log.h:111
Definition: audit_log.h:77
struct discord_audit_log_entries * audit_log_entries
Definition: audit_log.h:80
Definition: channel.h:683
char * content
Definition: channel.h:685
Definition: audit_log.h:163
u64snowflake user_id
Definition: audit_log.h:165
Definition: gateway.h:449
u64snowflake guild_id
Definition: gateway.h:451
struct discord_user * user
Definition: gateway.h:453
Definition: gateway.h:456
u64snowflake guild_id
Definition: gateway.h:458
struct discord_user * user
Definition: gateway.h:462
char * nick
Definition: gateway.h:464
struct discord_user * user
Definition: guild.h:293
u64snowflake guild_id
Definition: guild.h:328
Definition: channel.h:195
u64snowflake guild_id
Definition: channel.h:201
struct discord_user * author
Definition: channel.h:203
Definition: gateway.h:332
struct discord_user * user
Definition: gateway.h:336
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:73
void(* done)(struct discord *client, struct discord_response *resp, const struct discord_audit_log *ret)
Definition: discord-response.h:73
void(* fail)(struct discord *client, struct discord_response *resp)
Definition: discord-response.h:73
bool bot
Definition: user.h:79
char * username
Definition: user.h:73
char * discriminator
Definition: user.h:75
The Discord client handler.
Definition: discord-internal.h:1190