discord_timestamp - get current timestamp (client’s concept of now)

uint64_t discord_timestamp(struct discord *client)

Get the current timestamp (in milliseconds)

Parameters
Returns

the timestamp in milliseconds

Example

#include <inttypes.h> // PRIu64

// see https://discord.com/developers/docs/reference#message-formatting-formats
void on_current_time(struct discord *client,
                     const struct discord_message *msg)
{
  uint64_t now_ms = discord_timestamp(client);
  char text[256];
  sprintf(text, "<t:%" PRIu64 ">", now_ms / 1000);

  struct discord_create_message_params params = { .content = text };
  discord_create_message(client, msg->channel_id, &params, NULL);
}

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