Skip to content

Commit

Permalink
Merge pull request #46 from Slydelix/master
Browse files Browse the repository at this point in the history
Add user creation date to helpers
  • Loading branch information
PsychoTea authored Nov 20, 2018
2 parents 88e4b8e + 5d4c660 commit b26b676
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Oxide.Ext.Discord/Helpers/CreationTime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Oxide.Ext.Discord.Helpers
{
using Oxide.Ext.Discord.DiscordObjects;
using System;

public class CreationTime
{
public static DateTime GetFromUser(User user) => GetFromUserID(user.id);

public static DateTime GetFromUserID(string userID)
{
long id = long.Parse(userID);

long ageInSeconds = ((id >> 22) + 1420070400000) / 1000;

return new DateTime(1970, 1, 1).AddSeconds(ageInSeconds);
}
}
}
1 change: 1 addition & 0 deletions Oxide.Ext.Discord/Oxide.Ext.Discord.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<Compile Include="Gateway\Connect.cs" />
<Compile Include="Gateway\OpCodes.cs" />
<Compile Include="Gateway\RPayload.cs" />
<Compile Include="Helpers\CreationTime.cs" />
<Compile Include="Helpers\HttpUtility.cs" />
<Compile Include="DiscordObjects\Nick.cs" />
<Compile Include="DiscordObjects\ObjectPosition.cs" />
Expand Down

0 comments on commit b26b676

Please sign in to comment.