user12206173
user12206173

Reputation:

How to get my Discord bot's creation date?

I don't know how to get my Discord bot's creation date but I need it. Can someone tell me how?

Upvotes: 0

Views: 2352

Answers (2)

Lane
Lane

Reputation: 76

The client object gives you access to a class known as ClientUser (see here) and it allows you to access the createdAt property here (see here)

Example:

client.on('ready', () => {
        console.log(`[BOT] I'm ready! Logged in as ${client.user.tag}`);
        console.log(`Creation Date: ${client.user.createdAt}`);
});

Upvotes: 0

Caltrop
Caltrop

Reputation: 935

If you want to know when your Bot was started:

var creationDate = Date.now() - client.uptime

If you want to know when the actual files of your Bot were created, you can use fs for that.

var fs = require('fs');
fs.stat('./path/to/file.js', (err, stat) => {
   if(err) throw(err);
   var creationDate = stat.birthtime; //NOTE: this is unavailable on Linux 
})

If you want to know when the Account your Bot is using was created:

var creationDate = client.user.createdAt;

Upvotes: 3

Related Questions