discord_reconnect - reconnect a on-going connection#

void discord_reconnect(struct discord *client, bool resume)#

Gracefully reconnects an ongoing Discord connection.

Parameters:
  • client – the client created with discord_init()

  • resume – true to attempt to resume to previous session, false restart a fresh session

Example#

void on_reconnect(struct discord *client, const struct discord_message *msg)
{
  discord_reconnect(client, true);
  log_info("Client will be reconnected");
}

int main(void)
{
  struct discord *client = discord_init(BOT_TOKEN);
  discord_set_on_command(client, "!reconnect", &on_reconnect);
  discord_run(client);
  discord_cleanup(client);
}