#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
void
print_usage(void)
{
printf("\n\nThis bot demonstrates how easy it is to fetch"
" messages from a particular user (without even connecting"
" to Discord Gateway).\n"
"\nTYPE ANY KEY TO START BOT\n");
}
select_guild(
struct discord *client)
{
assert(
CCORD_OK == code && guilds.
size != 0 &&
"Couldn't fetch guilds");
printf(
"\n\nSelect the guild that the user you wish to fetch messages from "
"is part of");
int i = 0;
while (i < guilds.
size) {
printf(
"\n%d. %s", i + 1, guilds.
array[i].
name);
++i;
}
while (1) {
char strnum[10];
puts("\n\nNUMBER >>");
fgets(strnum, sizeof(strnum), stdin);
int num = strtol(strnum, NULL, 10);
if (num > 0 && num <= i) {
return guild_id;
}
printf("\nPlease, insert a value between 1 and %d", i);
}
}
{
&& "Guild is empty or bot needs to activate its privileged "
"intents.\n\t"
"See this guide to activate it: "
"https://discordpy.readthedocs.io/en/latest/"
"intents.html#privileged-intents");
printf("\n\nSelect the member that will have its messages fetched");
int i = 0;
while (i < members.
size) {
{
}
++i;
}
do {
char strnum[10];
puts("\n\nNUMBER >>");
fgets(strnum, sizeof(strnum), stdin);
int num = strtol(strnum, NULL, 10);
if (num > 0 && num <= i) {
return user_id;
}
printf("\nPlease, insert a value between 1 and %d", i);
} while (1);
}
void
fetch_member_msgs(
struct discord *client,
{
assert(
CCORD_OK == code &&
"Couldn't fetch channels from guild");
for (
int i = 0; i < channels.
size; ++i) {
int n_msg = 0;
while (n_msg != params.
limit) {
&ret);
for (n_msg = 0; n_msg < msgs.
size; ++n_msg) {
}
}
}
}
}
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);
fetch_member_msgs(client, guild_id, user_id);
}
CCORDcode ccord_global_init()
Initialize global shared-resources not API-specific.
void ccord_global_cleanup()
Cleanup global shared-resources.
Public functions and datatypes.
void discord_messages_cleanup(struct discord_messages *self)
void discord_channels_cleanup(struct discord_channels *self)
void discord_guilds_cleanup(struct discord_guilds *self)
void discord_guild_members_cleanup(struct discord_guild_members *self)
CCORDcode
Definition: error.h:12
@ CCORD_OK
Definition: error.h:42
uint64_t u64snowflake
Snowflake datatype.
Definition: types.h:28
CCORDcode discord_get_channel_messages(struct discord *client, u64snowflake channel_id, struct discord_get_channel_messages *params, struct discord_ret_messages *ret)
Get messages for a given channel.
CCORDcode discord_get_guild_channels(struct discord *client, u64snowflake guild_id, struct discord_ret_channels *ret)
Fetch channels from given guild. Does not include threads.
CCORDcode discord_list_guild_members(struct discord *client, u64snowflake guild_id, struct discord_list_guild_members *params, struct discord_ret_guild_members *ret)
Get guild members of a guild.
CCORDcode discord_get_current_user_guilds(struct discord *client, struct discord_ret_guilds *ret)
Get guilds client is a member of.
void discord_cleanup(struct discord *client)
Free a Discord Client handle.
struct discord * discord_config_init(const char config_file[])
Create a Discord Client handle by a config.json file.
u64snowflake id
Definition: channel.h:124
Definition: channel.h:191
struct discord_channel * array
Definition: channel.h:192
int size
Definition: channel.h:191
Definition: channel.h:664
u64snowflake before
Definition: channel.h:671
int limit
Definition: channel.h:679
struct discord_user * user
Definition: guild.h:293
char * nick
Definition: guild.h:297
struct discord_guild_member * array
Definition: guild.h:332
int size
Definition: guild.h:331
char * name
Definition: guild.h:93
u64snowflake id
Definition: guild.h:90
struct discord_guild * array
Definition: guild.h:238
int size
Definition: guild.h:237
int limit
Definition: guild.h:591
u64snowflake id
Definition: channel.h:197
char * content
Definition: channel.h:207
struct discord_user * author
Definition: channel.h:203
Definition: channel.h:265
int size
Definition: channel.h:265
struct discord_message * array
Definition: channel.h:266
Request's return context.
Definition: discord-response.h:85
struct discord_channels * sync
Definition: discord-response.h:85
Request's return context.
Definition: discord-response.h:105
struct discord_guild_members * sync
Definition: discord-response.h:105
Request's return context.
Definition: discord-response.h:102
struct discord_guilds * sync
Definition: discord-response.h:102
Request's return context.
Definition: discord-response.h:87
u64snowflake id
Definition: user.h:71
char * username
Definition: user.h:73
The Discord client handler.
Definition: discord-internal.h:1190