PsychoTea / Oxide.Ext.Discord

Discord extension and integration
https://umod.org/extensions/discord
12 stars 25 forks source link

Add CreatedAt property to User object #41

Closed Slydelix closed 5 years ago

Slydelix commented 5 years ago

This works by calculating the age from the user's ID (more info at link)

Returns user's account creation date in DateTime (UTC)

PsychoTea commented 5 years ago

A simple bit-shift and addition calculation will give you the time since epoch (as demonstrated in the docs):

(value >> 22) + 1420070400000

You can then more easily convert this into a DateTime object.

Furthermore, the DiscordObjects namespace's' classes should only contain models of data, similar to the MVC architecture. Due to this, it would be better to move this functionality out to a "helper" class.

Slydelix commented 5 years ago

Okay, I'll look into it and probably create a new pull request with updated stuff