using System;
using System.Data.Common;
namespace Kerobot // Publicly accessible class; placing in main namespace
{
///
/// Representation of user information retrieved from Kerobot's UserCache.
///
public class CachedUser
{
///
/// The user's snowflake ID.
///
public ulong UserID { get; }
///
/// The corresponding guild's snowflake ID.
///
public ulong GuildID { get; }
///
/// The date in which this user was first recorded onto the database.
///
public DateTimeOffset FirstSeenDate { get; }
///
/// The date in which cache information for this user was last updated.
///
public DateTimeOffset CacheDate { get; }
///
/// The user's corresponding username, without discriminator.
///
public string Username { get; }
///
/// The user's corresponding discriminator value.
///
public string Discriminator { get; }
///
/// The user's nickname in the corresponding guild. May be null.
///
public string Nickname { get; }
///
/// A link to a high resolution version of the user's current avatar. May be null.
///
public string AvatarUrl { get; }
internal CachedUser(DbDataReader row)
{
// Highly dependent on column order in the cache view defined in UserCacheService.
unchecked
{
UserID = (ulong)row.GetInt64(0);
GuildID = (ulong)row.GetInt64(1);
}
FirstSeenDate = row.GetDateTime(2).ToUniversalTime();
CacheDate = row.GetDateTime(3).ToUniversalTime();
Username = row.GetString(4);
Discriminator = row.GetString(5);
Nickname = row.IsDBNull(6) ? null : row.GetString(6);
AvatarUrl = row.IsDBNull(7) ? null : row.GetString(7);
}
}
}