From e1baa3942a2161f77dbc9878c2eb7176b23d3ed9 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sun, 25 Jun 2017 02:35:37 +0200 Subject: [PATCH] .gc and stream follows should properly persist restarts --- .../Modules/Administration/Commands/SelfCommands.cs | 8 ++++---- .../Modules/Games/Commands/PlantAndPickCommands.cs | 2 +- src/NadekoBot/Modules/Utility/Utility.cs | 2 -- src/NadekoBot/NadekoBot.cs | 11 ++++------- src/NadekoBot/Resources/CommandStrings.resx | 10 +++++----- .../Repositories/Impl/GuildConfigRepository.cs | 1 + 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs b/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs index 5e5ecb33..449398b4 100644 --- a/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs @@ -14,6 +14,7 @@ using NadekoBot.Services.Database.Models; using Microsoft.EntityFrameworkCore; using NadekoBot.Services.Administration; using System.Diagnostics; +using NadekoBot.DataStructures; namespace NadekoBot.Modules.Administration { @@ -207,12 +208,11 @@ namespace NadekoBot.Modules.Administration //todo 2 shard commands //[NadekoCommand, Usage, Description, Aliases] + //[Shard0Precondition] //[OwnerOnly] - //public async Task ConnectShard(int shardid) + //public async Task RestartShard(int shardid) //{ - // var shard = _client.GetShard(shardid); - - // if (shard == null) + // if (shardid == 0 || shardid > b) // { // await ReplyErrorLocalized("no_shard_id").ConfigureAwait(false); // return; diff --git a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs index 191fd30d..f055e0bb 100644 --- a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs @@ -116,7 +116,7 @@ namespace NadekoBot.Modules.Games bool enabled; using (var uow = _db.UnitOfWork) { - var guildConfig = uow.GuildConfigs.For(channel.Id, set => set.Include(gc => gc.GenerateCurrencyChannelIds)); + var guildConfig = uow.GuildConfigs.For(channel.Guild.Id, set => set.Include(gc => gc.GenerateCurrencyChannelIds)); var toAdd = new GCChannelId() { ChannelId = channel.Id }; if (!guildConfig.GenerateCurrencyChannelIds.Contains(toAdd)) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 3ae25163..7a6f9ae1 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -299,8 +299,6 @@ namespace NadekoBot.Modules.Utility Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.ToString()))) .ToArray(); - - await Context.Channel.SendPaginatedConfirmAsync(_client, page, (curPage) => { diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 24033c1f..a180f3b5 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -4,8 +4,6 @@ using Discord.WebSocket; using NadekoBot.Services; using NadekoBot.Services.Impl; using NLog; -using NLog.Config; -using NLog.Targets; using System; using System.Linq; using System.Reflection; @@ -28,8 +26,6 @@ using NadekoBot.Services.Help; using System.IO; using NadekoBot.Services.Pokemon; using NadekoBot.DataStructures.ShardCom; -using NadekoBot.DataStructures; -using NadekoBot.Extensions; namespace NadekoBot { @@ -295,9 +291,10 @@ namespace NadekoBot clientReady.TrySetResult(true); try { - await Task.WhenAll((await Client.GetDMChannelsAsync()) - .Select(x => x.CloseAsync())) - .ConfigureAwait(false); + foreach (var chan in (await Client.GetDMChannelsAsync())) + { + await chan.CloseAsync().ConfigureAwait(false); + } } catch { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 708abfe8..e896535d 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -3096,14 +3096,14 @@ `{0}shardstats` or `{0}shardstats 2` - - connectshard + + restartshard - + Try (re)connecting a shard with a certain shardid when it dies. No one knows will it work. Keep an eye on the console for errors. - - `{0}connectshard 2` + + `{0}restartshard 2` shardid diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs index 37d2af60..3628a4e9 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/GuildConfigRepository.cs @@ -44,6 +44,7 @@ namespace NadekoBot.Services.Database.Repositories.Impl .Include(gc => gc.SlowmodeIgnoredUsers) .Include(gc => gc.AntiSpamSetting) .ThenInclude(x => x.IgnoredChannels) + .Include(gc => gc.FollowedStreams) .ToList(); ///