Update DiscordAuthManager.cs

This commit is contained in:
Deserty0
2025-08-12 00:24:43 +10:00
parent 35e5025d3e
commit b0c2b92464

View File

@@ -270,9 +270,11 @@ public sealed class DiscordAuthManager
private double GetAccountAge(string id)
{
// Please check https://discord.com/developers/docs/reference#convert-snowflake-to-datetime
var unixEpoch = 1420070400000;
var intId = Convert.ToInt32(id);
var snowflakeCreationDateBin = Convert.ToString(intId, 2).Substring(42);
var snowflakeCreationDateDecimal = Convert.ToInt32(snowflakeCreationDateBin) + 1420070400000;
var snowflakeCreationDateDecimal = Convert.ToInt32(snowflakeCreationDateBin) + unixEpoch;
var accountCreationDate = DateTime.UnixEpoch.AddSeconds(snowflakeCreationDateDecimal);
var accountAge = DateTime.Now.Subtract(accountCreationDate);
return accountAge.TotalDays;