diff --git a/docs/guides/OSX Guide.md b/docs/guides/OSX Guide.md index 00042cfd..7475a911 100644 --- a/docs/guides/OSX Guide.md +++ b/docs/guides/OSX Guide.md @@ -58,7 +58,7 @@ A dialog box will open asking if you want to install `xcode-select`. Select inst Use the following command to get and run `linuxAIO.sh`: (Remember **DO NOT** rename the file `linuxAIO.sh`) -`cd ~ && wget https://github.com/Kwoth/NadekoBot-BashScript/raw/master/linuxAIO.sh && bash linuxAIO.sh` +`cd ~ && wget -N https://github.com/Kwoth/NadekoBot-BashScript/raw/master/linuxAIO.sh && bash linuxAIO.sh` Follow the on screen instructions: 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); } } 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] 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) { diff --git a/src/NadekoBot/ShardedDiscordClient.cs b/src/NadekoBot/ShardedDiscordClient.cs index 014f0edc..892bc6d8 100644 --- a/src/NadekoBot/ShardedDiscordClient.cs +++ b/src/NadekoBot/ShardedDiscordClient.cs @@ -79,13 +79,32 @@ 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 + { + _log.Error($"Shard #{c.ShardId} FAILED CONNECTING."); + try { await c.ConnectAsync().ConfigureAwait(false); } + catch (Exception ex2) + { + _log.Error($"Shard #{c.ShardId} FAILED CONNECTING TWICE."); + _log.Error(ex2); + } + } + } + } 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) {