refactor(examples/bot-presence.c): set client's status at READY callback
@@ -11,6 +11,21 @@ void on_ready(struct discord *client)
log_info("Presence-Bot succesfully connected to Discord as %s#%s!",
bot->username, bot->discriminator);
+
+ discord_set_presence(client, &(struct discord_presence_status){
+ .activities =
+ (struct discord_activity *[]){
+ &(struct discord_activity){
+ .name = "with Orca",
+ .type = DISCORD_ACTIVITY_GAME,
+ .details = "Fixing some bugs",
+ },
+ NULL // END OF ACTIVITY ARRAY
+ },
+ .status = "idle",
+ .afk = false,
+ .since = discord_timestamp(client),
+ });
}
int main(int argc, char *argv[])
@@ -25,28 +40,14 @@ int main(int argc, char *argv[])
struct discord *client = discord_config_init(config_file);
assert(NULL != client && "Couldn't initialize client");
+ discord_set_on_ready(client, &on_ready);
+
printf("\n\nThis bot demonstrates how easy it is to set the bot presence.\n"
"1. Login\n"
"2. Check the bot status\n"
"\nTYPE ANY KEY TO START BOT\n");
fgetc(stdin); // wait for input
- /* custom presence */
- discord_set_presence(client, &(struct discord_presence_status){
- .activities =
- (struct discord_activity *[]){
- &(struct discord_activity){
- .name = "with Orca",
- .type = DISCORD_ACTIVITY_GAME,
- .details = "Fixing some bugs",
- },
- NULL // END OF ACTIVITY ARRAY
- },
- .status = "idle",
- .afk = false,
- .since = discord_timestamp(client),
- });
-
discord_run(client);
discord_cleanup(client);
