Default LastActivity to null until activity is seen, trigger with voice activity.
This commit is contained in:
@@ -118,6 +118,12 @@ namespace Discord
|
|||||||
{
|
{
|
||||||
if (_voiceSocket.CurrentVoiceServerId != null)
|
if (_voiceSocket.CurrentVoiceServerId != null)
|
||||||
{
|
{
|
||||||
|
if (_config.TrackActivity)
|
||||||
|
{
|
||||||
|
var user = _users[e.UserId];
|
||||||
|
if (user != null)
|
||||||
|
user.UpdateActivity();
|
||||||
|
}
|
||||||
var member = _members[e.UserId, _voiceSocket.CurrentVoiceServerId];
|
var member = _members[e.UserId, _voiceSocket.CurrentVoiceServerId];
|
||||||
bool value = e.IsSpeaking;
|
bool value = e.IsSpeaking;
|
||||||
if (member.IsSpeaking != value)
|
if (member.IsSpeaking != value)
|
||||||
|
|||||||
@@ -44,17 +44,14 @@ namespace Discord
|
|||||||
public IEnumerable<Server> Servers => _client.Servers.Where(x => x.HasMember(Id));
|
public IEnumerable<Server> Servers => _client.Servers.Where(x => x.HasMember(Id));
|
||||||
/// <summary> Returns a collection of all messages this user has sent that are still in cache. </summary>
|
/// <summary> Returns a collection of all messages this user has sent that are still in cache. </summary>
|
||||||
public IEnumerable<Message> Messages => _client.Messages.Where(x => x.UserId == Id);
|
public IEnumerable<Message> Messages => _client.Messages.Where(x => x.UserId == Id);
|
||||||
|
|
||||||
//TODO: Add voice triggering LastActivity
|
|
||||||
/// <summary> Returns the time this user last sent a message. </summary>
|
/// <summary> Returns the time this user last sent a message. </summary>
|
||||||
/// <remarks> Is not currently affected by voice activity. </remarks>
|
public DateTime? LastActivity { get; private set; }
|
||||||
public DateTime LastActivity { get; private set; }
|
|
||||||
|
|
||||||
internal User(DiscordClient client, string id)
|
internal User(DiscordClient client, string id)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
Id = id;
|
Id = id;
|
||||||
LastActivity = DateTime.UtcNow;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Update(UserReference model)
|
internal void Update(UserReference model)
|
||||||
@@ -70,10 +67,10 @@ namespace Discord
|
|||||||
IsVerified = model.IsVerified;
|
IsVerified = model.IsVerified;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void UpdateActivity(DateTime activity)
|
internal void UpdateActivity(DateTime? activity)
|
||||||
{
|
{
|
||||||
if (activity > LastActivity)
|
if (LastActivity == null || activity > LastActivity.Value)
|
||||||
LastActivity = activity;
|
LastActivity = activity ?? DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => Name;
|
public override string ToString() => Name;
|
||||||
|
|||||||
Reference in New Issue
Block a user