Fixes to .stats

This commit is contained in:
Kwoth 2017-01-07 18:41:10 +01:00
parent 21c6c5fc9a
commit 37d462712c
2 changed files with 20 additions and 7 deletions

View File

@ -23,10 +23,10 @@ namespace NadekoBot.Services.Impl
public string Heap => public string Heap =>
Math.Round((double)GC.GetTotalMemory(false) / 1.MiB(), 2).ToString(); Math.Round((double)GC.GetTotalMemory(false) / 1.MiB(), 2).ToString();
public double MessagesPerSecond => MessageCounter / (double)GetUptime().TotalSeconds; public double MessagesPerSecond => MessageCounter / (double)GetUptime().TotalSeconds;
private uint _textChannels = 0; private int _textChannels = 0;
public uint TextChannels => _textChannels; public int TextChannels => _textChannels;
private uint _voiceChannels = 0; private int _voiceChannels = 0;
public uint VoiceChannels => _voiceChannels; public int VoiceChannels => _voiceChannels;
public string OwnerIds => string.Join(", ", NadekoBot.Credentials.OwnerIds); public string OwnerIds => string.Join(", ", NadekoBot.Credentials.OwnerIds);
Timer carbonitexTimer { get; } Timer carbonitexTimer { get; }
@ -42,9 +42,12 @@ namespace NadekoBot.Services.Impl
this.client.Disconnected += _ => Reset(); this.client.Disconnected += _ => Reset();
this.client.Connected += () =>
{
var guilds = this.client.GetGuilds(); var guilds = this.client.GetGuilds();
var _textChannels = guilds.Sum(g => g.Channels.Where(cx => cx is ITextChannel).Count()); _textChannels = guilds.Sum(g => g.Channels.Where(cx => cx is ITextChannel).Count());
var _voiceChannels = guilds.Sum(g => g.Channels.Count) - _textChannels; _voiceChannels = guilds.Sum(g => g.Channels.Count) - _textChannels;
};
this.client.ChannelCreated += (c) => this.client.ChannelCreated += (c) =>
{ {
@ -70,6 +73,14 @@ namespace NadekoBot.Services.Impl
_voiceChannels += vc; _voiceChannels += vc;
}; };
this.client.LeftGuild += (g) =>
{
var tc = g.Channels.Where(cx => cx is ITextChannel).Count();
var vc = g.Channels.Count - tc;
_textChannels -= tc;
_voiceChannels -= vc;
};
this.carbonitexTimer = new Timer(async (state) => this.carbonitexTimer = new Timer(async (state) =>
{ {
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.CarbonKey)) if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.CarbonKey))

View File

@ -33,6 +33,7 @@ namespace NadekoBot
public event Action<SocketGuild> LeftGuild = delegate { }; public event Action<SocketGuild> LeftGuild = delegate { };
public event Action<Exception> Disconnected = delegate { }; public event Action<Exception> Disconnected = delegate { };
public event Action Connected = delegate { };
private uint _connectedCount = 0; private uint _connectedCount = 0;
private uint _downloadedCount = 0; private uint _downloadedCount = 0;
@ -145,6 +146,7 @@ namespace NadekoBot
} }
} }
} }
Connected();
} }
internal Task DownloadAllUsersAsync() => internal Task DownloadAllUsersAsync() =>