From 0aa65b29534dc1fe376cb4b44b789d87409c381a Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 22 Jun 2017 03:39:26 +0200 Subject: [PATCH] Fixes to remind and shardstats --- .../Modules/Utility/Commands/Remind.cs | 4 +- src/NadekoBot/NadekoBot.cs | 3 + .../Services/Administration/SelfService.cs | 58 +++++++++---------- src/NadekoBot/ShardsCoordinator.cs | 5 +- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Commands/Remind.cs b/src/NadekoBot/Modules/Utility/Commands/Remind.cs index 448ec424..ce046467 100644 --- a/src/NadekoBot/Modules/Utility/Commands/Remind.cs +++ b/src/NadekoBot/Modules/Utility/Commands/Remind.cs @@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Utility [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - [Priority(1)] + [Priority(0)] public async Task Remind(MeOrHere meorhere, string timeStr, [Remainder] string message) { ulong target; @@ -44,7 +44,7 @@ namespace NadekoBot.Modules.Utility [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] [RequireUserPermission(GuildPermission.ManageMessages)] - [Priority(0)] + [Priority(1)] public async Task Remind(ITextChannel channel, string timeStr, [Remainder] string message) { var perms = ((IGuildUser)Context.User).GetPermissions((ITextChannel)channel); diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 53288c5c..e6dc2d5c 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -363,10 +363,13 @@ namespace NadekoBot public async Task RunAndBlockAsync(params string[] args) { await RunAsync(args).ConfigureAwait(false); + StartSendingData(); if (ShardCoord != null) await ShardCoord.RunAndBlockAsync(); else + { await Task.Delay(-1).ConfigureAwait(false); + } } private void TerribleElevatedPermissionCheck() diff --git a/src/NadekoBot/Services/Administration/SelfService.cs b/src/NadekoBot/Services/Administration/SelfService.cs index 0c5b6e48..0a288a0b 100644 --- a/src/NadekoBot/Services/Administration/SelfService.cs +++ b/src/NadekoBot/Services/Administration/SelfService.cs @@ -72,39 +72,39 @@ namespace NadekoBot.Services.Administration }); } - private void LoadOwnerChannels() - { - var hs = new HashSet(_creds.OwnerIds); - var channels = new Dictionary>(); + //private void LoadOwnerChannels() + //{ + // var hs = new HashSet(_creds.OwnerIds); + // var channels = new Dictionary>(); - if (hs.Count > 0) - { - foreach (var g in _client.Guilds) - { - if (hs.Count == 0) - break; + // if (hs.Count > 0) + // { + // foreach (var g in _client.Guilds) + // { + // if (hs.Count == 0) + // break; - foreach (var u in g.Users) - { - if (hs.Remove(u.Id)) - { - channels.Add(u.Id, new AsyncLazy(async () => await u.CreateDMChannelAsync())); - if (hs.Count == 0) - break; - } - } - } - } + // foreach (var u in g.Users) + // { + // if (hs.Remove(u.Id)) + // { + // channels.Add(u.Id, new AsyncLazy(async () => await u.CreateDMChannelAsync())); + // if (hs.Count == 0) + // break; + // } + // } + // } + // } - ownerChannels = channels.OrderBy(x => _creds.OwnerIds.IndexOf(x.Key)) - .Select(x => x.Value) - .ToImmutableArray(); + // ownerChannels = channels.OrderBy(x => _creds.OwnerIds.IndexOf(x.Key)) + // .Select(x => x.Value) + // .ToImmutableArray(); - if (!ownerChannels.Any()) - _log.Warn("No owner channels created! Make sure you've specified correct OwnerId in the credentials.json file."); - else - _log.Info($"Created {ownerChannels.Length} out of {_creds.OwnerIds.Length} owner message channels."); - } + // if (!ownerChannels.Any()) + // _log.Warn("No owner channels created! Make sure you've specified correct OwnerId in the credentials.json file."); + // else + // _log.Info($"Created {ownerChannels.Length} out of {_creds.OwnerIds.Length} owner message channels."); + //} // forwards dms public async Task LateExecute(DiscordSocketClient client, IGuild guild, IUserMessage msg) diff --git a/src/NadekoBot/ShardsCoordinator.cs b/src/NadekoBot/ShardsCoordinator.cs index 9f848389..4ed8247f 100644 --- a/src/NadekoBot/ShardsCoordinator.cs +++ b/src/NadekoBot/ShardsCoordinator.cs @@ -78,7 +78,10 @@ namespace NadekoBot .Where(x => x != null) .GroupBy(x => x.ConnectionState) .Select(x => x.Count() + " " + x.Key)); - _log.Info(string.Join("\n", Statuses.Select(x => $"Shard {x.ShardId} is in {x.ConnectionState.ToString()} state with {x.Guilds} servers")) + "\n" + groupStr); + _log.Info(string.Join("\n", Statuses + .ToArray() + .Where(x => x != null) + .Select(x => $"Shard {x.ShardId} is in {x.ConnectionState.ToString()} state with {x.Guilds} servers")) + "\n" + groupStr); break; default: break;