#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <assert.h>
void
print_usage(void)
{
printf(
"\n\nThis bot demonstrates how easy it is to fetch/delete invites\n"
"1. Type 'invite.get <invite_code>' to get a invite object from its "
"particular code\n"
"2. Type 'invite.delete <invite_code>' to delete a invite object by "
"its particular code\n"
"\nTYPE ANY KEY TO START BOT\n");
}
void
on_ready(
struct discord *client,
const struct discord_ready *event)
{
"Invite-Bot succesfully connected to Discord as %s#%s!",
event->user->username, event->user->discriminator);
}
void
const struct discord_invite *invite)
{
const struct discord_message *
event = resp->
keep;
char text[256];
snprintf(text, sizeof(text), "Success: https://discord.gg/%s",
invite->code);
}
void
{
const struct discord_message *
event = resp->
keep;
.content = "Couldn't perform operation."
};
}
void
on_invite_get(
struct discord *client,
const struct discord_message *event)
{
if (event->author->bot) return;
.keep = event,
};
.with_counts = true,
.with_expiration = true,
};
}
void
on_invite_delete(
struct discord *client,
const struct discord_message *event)
{
if (event->author->bot) return;
.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 && "Could not 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_delete_invite(struct discord *client, char *invite_code, struct discord_delete_invite *params, struct discord_ret_invite *ret)
Delete an invite.
CCORDcode discord_get_invite(struct discord *client, char *invite_code, struct discord_get_invite *params, struct discord_ret_invite *ret)
Get an invite for the given code.
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.
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
Request's return context.
Definition: discord-response.h:137
void(* done)(struct discord *client, struct discord_response *resp, const struct discord_invite *ret)
Definition: discord-response.h:137
void(* fail)(struct discord *client, struct discord_response *resp)
Definition: discord-response.h:137
The Discord client handler.
Definition: discord-internal.h:1206