From 1368e1e929f7541b94fb6a94c21cc232a7a80c2a Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 15 Dec 2016 16:51:09 +0100 Subject: [PATCH 1/5] Music warning fixed --- src/NadekoBot/Modules/Music/Music.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index 4a8e4829..81e5c95d 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -112,16 +112,16 @@ namespace NadekoBot.Modules.Music [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task Pause(IUserMessage umsg) + public Task Pause(IUserMessage umsg) { var channel = (ITextChannel)umsg.Channel; MusicPlayer musicPlayer; - if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return; + if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer)) return Task.CompletedTask; if (((IGuildUser)umsg.Author).VoiceChannel != musicPlayer.PlaybackVoiceChannel) - return; + return Task.CompletedTask; musicPlayer.TogglePause(); - + return Task.CompletedTask; } [NadekoCommand, Usage, Description, Aliases] From e0150e605ada213c3604dd76757cf6a4d36e8583 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 15 Dec 2016 19:20:26 +0100 Subject: [PATCH 2/5] .listquotes now shows this server's quotes --- src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs | 2 +- .../Services/Database/Repositories/IQuoteRepository.cs | 2 +- .../Services/Database/Repositories/Impl/QuoteRepository.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index cb4eb654..41ce9aa8 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Utility IEnumerable quotes; using (var uow = DbHandler.UnitOfWork()) { - quotes = uow.Quotes.GetGroup(page * 16, 16); + quotes = uow.Quotes.GetGroup(channel.Guild.Id, page * 16, 16); } if (quotes.Any()) diff --git a/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs b/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs index a3a92efd..e3ca6ec1 100644 --- a/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/IQuoteRepository.cs @@ -8,6 +8,6 @@ namespace NadekoBot.Services.Database.Repositories { IEnumerable GetAllQuotesByKeyword(ulong guildId, string keyword); Task GetRandomQuoteByKeywordAsync(ulong guildId, string keyword); - IEnumerable GetGroup(int skip, int take); + IEnumerable GetGroup(ulong guildId, int skip, int take); } } diff --git a/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs b/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs index df8bddb6..22c6e5c9 100644 --- a/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs +++ b/src/NadekoBot/Services/Database/Repositories/Impl/QuoteRepository.cs @@ -15,8 +15,8 @@ namespace NadekoBot.Services.Database.Repositories.Impl public IEnumerable GetAllQuotesByKeyword(ulong guildId, string keyword) => _set.Where(q => q.GuildId == guildId && q.Keyword == keyword); - public IEnumerable GetGroup(int skip, int take) => - _set.OrderBy(q => q.Keyword).Skip(skip).Take(take).ToList(); + public IEnumerable GetGroup(ulong guildId, int skip, int take) => + _set.Where(q=>q.GuildId == guildId).OrderBy(q => q.Keyword).Skip(skip).Take(take).ToList(); public Task GetRandomQuoteByKeywordAsync(ulong guildId, string keyword) { From ab604df28be886ac3e6b91c520aa2f2c48cee75a Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 15 Dec 2016 19:28:08 +0100 Subject: [PATCH 3/5] weird --- src/NadekoBot/Modules/Gambling/Gambling.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index cc4e123b..efd0f1fa 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -221,7 +221,7 @@ namespace NadekoBot.Modules.Gambling { var channel = (ITextChannel)umsg.Channel; - IEnumerable richest; + IEnumerable richest = new List(); using (var uow = DbHandler.UnitOfWork()) { richest = uow.Currency.GetTopRichest(10); @@ -235,7 +235,7 @@ $@"```xl ┃ Id ┃ $$$ ┃ "), (cur, cs) => cur.AppendLine($@"┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫ -┃{(channel.Guild.GetUser(cs.UserId)?.Username.TrimTo(18, true) ?? cs.UserId.ToString()),-20} ┃ {cs.Amount,6} ┃") +┃{(channel.Guild.GetUser(cs.UserId)?.Username?.TrimTo(18, true) ?? cs.UserId.ToString()),-20} ┃ {cs.Amount,6} ┃") ).ToString() + "┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━┛```").ConfigureAwait(false); } } From f55d3f68d3c5242657376ca5c4c15eb1756c0c04 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 15 Dec 2016 20:10:55 +0100 Subject: [PATCH 4/5] Trying to fix connection failed problem --- src/NadekoBot/ShardedDiscordClient.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/ShardedDiscordClient.cs b/src/NadekoBot/ShardedDiscordClient.cs index 014f0edc..59d6d776 100644 --- a/src/NadekoBot/ShardedDiscordClient.cs +++ b/src/NadekoBot/ShardedDiscordClient.cs @@ -79,13 +79,27 @@ namespace NadekoBot Clients[0].GetDMChannelAsync(channelId); internal Task LoginAsync(TokenType tokenType, string token) => - Task.WhenAll(Clients.Select(async c => { await c.LoginAsync(tokenType, token); _log.Info($"Shard #{c.ShardId} logged in."); })); + Task.WhenAll(Clients.Select(async c => { await c.LoginAsync(tokenType, token).ConfigureAwait(false); _log.Info($"Shard #{c.ShardId} logged in."); })); - internal Task ConnectAsync() => - Task.WhenAll(Clients.Select(async c => { await c.ConnectAsync(); _log.Info($"Shard #{c.ShardId} connected."); })); + internal async Task ConnectAsync() + { + foreach (var c in Clients) + { + try + { + await c.ConnectAsync().ConfigureAwait(false); + _log.Info($"Shard #{c.ShardId} connected."); + } + catch (Exception ex) + { + _log.Error($"Shard #{c.ShardId} FAILED CONNECTING."); + _log.Error(ex); + } + } + } internal Task DownloadAllUsersAsync() => - Task.WhenAll(Clients.Select(async c => { await c.DownloadAllUsersAsync(); _log.Info($"Shard #{c.ShardId} downloaded {c.GetGuilds().Sum(g => g.GetUsers().Count)} users."); })); + Task.WhenAll(Clients.Select(async c => { await c.DownloadAllUsersAsync().ConfigureAwait(false); _log.Info($"Shard #{c.ShardId} downloaded {c.GetGuilds().Sum(g => g.GetUsers().Count)} users."); })); public async Task SetGame(string game) { From 39f3ee01900a93823050902dfc162c1150edbc68 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 15 Dec 2016 20:26:02 +0100 Subject: [PATCH 5/5] Try 2 times --- src/NadekoBot/ShardedDiscordClient.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/ShardedDiscordClient.cs b/src/NadekoBot/ShardedDiscordClient.cs index 59d6d776..892bc6d8 100644 --- a/src/NadekoBot/ShardedDiscordClient.cs +++ b/src/NadekoBot/ShardedDiscordClient.cs @@ -90,10 +90,15 @@ namespace NadekoBot await c.ConnectAsync().ConfigureAwait(false); _log.Info($"Shard #{c.ShardId} connected."); } - catch (Exception ex) + catch { _log.Error($"Shard #{c.ShardId} FAILED CONNECTING."); - _log.Error(ex); + try { await c.ConnectAsync().ConfigureAwait(false); } + catch (Exception ex2) + { + _log.Error($"Shard #{c.ShardId} FAILED CONNECTING TWICE."); + _log.Error(ex2); + } } } }