diff --git a/Discord.Net b/Discord.Net index 7c0cce6d..05e73771 160000 --- a/Discord.Net +++ b/Discord.Net @@ -1 +1 @@ -Subproject commit 7c0cce6d35b04d883cf5ec2d775b051e4bc8739f +Subproject commit 05e7377142b8d8ccfabe0236dd8d2c40fb8d4bbf diff --git a/src/NadekoBot/Modules/Administration/Commands/AutoAssignRoleCommands.cs b/src/NadekoBot/Modules/Administration/Commands/AutoAssignRoleCommands.cs index e3cb8380..01c19fa8 100644 --- a/src/NadekoBot/Modules/Administration/Commands/AutoAssignRoleCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/AutoAssignRoleCommands.cs @@ -25,7 +25,6 @@ namespace NadekoBot.Modules.Administration static AutoAssignRoleCommands() { _log = LogManager.GetCurrentClassLogger(); - var sw = Stopwatch.StartNew(); AutoAssignedRoles = new ConcurrentDictionary(NadekoBot.AllGuildConfigs.Where(x => x.AutoAssignRoleId != 0) .ToDictionary(k => k.GuildId, v => v.AutoAssignRoleId)); @@ -46,9 +45,6 @@ namespace NadekoBot.Modules.Administration } catch (Exception ex) { _log.Warn(ex); } }; - - sw.Stop(); - _log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s"); } [NadekoCommand, Usage, Description, Aliases] diff --git a/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs b/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs index a087e6f2..13817a65 100644 --- a/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs @@ -132,7 +132,7 @@ namespace NadekoBot.Modules.Administration if (ids[1].ToUpperInvariant().StartsWith("C:")) { var cid = ulong.Parse(ids[1].Substring(2)); - var ch = (await server.GetTextChannelsAsync()).Where(c => c.Id == cid).FirstOrDefault(); + var ch = server.TextChannels.Where(c => c.Id == cid).FirstOrDefault(); if (ch == null) { return; @@ -159,9 +159,7 @@ namespace NadekoBot.Modules.Administration [OwnerOnly] public async Task Announce([Remainder] string message) { - var channels = await Task.WhenAll(NadekoBot.Client.GetGuilds().Select(g => - g.GetDefaultChannelAsync() - )).ConfigureAwait(false); + var channels = NadekoBot.Client.GetGuilds().Select(g => g.DefaultChannel).ToArray(); if (channels == null) return; await Task.WhenAll(channels.Where(c => c != null).Select(c => c.SendConfirmAsync($"🆕 Message from {Context.User} `[Bot Owner]`:", message))) diff --git a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs index a52a2c60..1bd135d8 100644 --- a/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/VoicePlusTextCommands.cs @@ -57,7 +57,7 @@ namespace NadekoBot.Modules.Administration { try { - await (await guild.GetOwnerAsync()).SendErrorAsync( + await guild.Owner.SendErrorAsync( "⚠️ I don't have **manage server** and/or **manage channels** permission," + $" so I cannot run `voice+text` on **{guild.Name}** server.").ConfigureAwait(false); } @@ -75,16 +75,16 @@ namespace NadekoBot.Modules.Administration var beforeVch = before.VoiceChannel; if (beforeVch != null) { - var textChannel = (await guild.GetTextChannelsAsync()).Where(t => t.Name == GetChannelName(beforeVch.Name).ToLowerInvariant()).FirstOrDefault(); + var textChannel = guild.TextChannels.Where(t => t.Name == GetChannelName(beforeVch.Name).ToLowerInvariant()).FirstOrDefault(); if (textChannel != null) await textChannel.AddPermissionOverwriteAsync(user, new OverwritePermissions(readMessages: PermValue.Deny, sendMessages: PermValue.Deny)).ConfigureAwait(false); } var afterVch = after.VoiceChannel; - if (afterVch != null && guild.AFKChannelId != afterVch.Id) + if (afterVch != null && guild.AFKChannel.Id != afterVch.Id) { - var textChannel = (await guild.GetTextChannelsAsync()) + ITextChannel textChannel = guild.TextChannels .Where(t => t.Name == GetChannelName(afterVch.Name).ToLowerInvariant()) .FirstOrDefault(); if (textChannel == null) diff --git a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs index 26b18995..4fc33705 100644 --- a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs +++ b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs @@ -37,9 +37,7 @@ namespace NadekoBot.Modules.ClashOfClans .Select(cw => { cw.Channel = NadekoBot.Client.GetGuild(cw.GuildId) - ?.GetTextChannelAsync(cw.ChannelId) - .GetAwaiter() - .GetResult(); + .GetTextChannel(cw.ChannelId); return cw; }) .Where(cw => cw.Channel != null) @@ -322,7 +320,7 @@ namespace NadekoBot.Modules.ClashOfClans public static async Task CreateWar(string enemyClan, int size, ulong serverId, ulong channelId) { - var channel = await NadekoBot.Client.GetGuild(serverId)?.GetTextChannelAsync(channelId); + var channel = NadekoBot.Client.GetGuild(serverId)?.GetTextChannel(channelId); using (var uow = DbHandler.UnitOfWork()) { var cw = new ClashWar diff --git a/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs b/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs index 5df56e36..598a19b0 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/CurrencyEvents.cs @@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Gambling catch { try { await msg.DeleteAsync().ConfigureAwait(false); } - catch { } + catch { return; } } } using (msg.OnReaction(async (r) => diff --git a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs index 08e9a9c8..2646ebd5 100644 --- a/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs +++ b/src/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs @@ -76,9 +76,9 @@ namespace NadekoBot.Modules.Games.Trivia questionMessage = await channel.EmbedAsync(questionEmbed).ConfigureAwait(false); } - catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound || - ex.StatusCode == System.Net.HttpStatusCode.Forbidden || - ex.StatusCode == System.Net.HttpStatusCode.BadRequest) + catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.NotFound || + ex.HttpCode == System.Net.HttpStatusCode.Forbidden || + ex.HttpCode == System.Net.HttpStatusCode.BadRequest) { return; } @@ -106,7 +106,7 @@ namespace NadekoBot.Modules.Games.Trivia await questionMessage.ModifyAsync(m => m.Embed = questionEmbed.WithFooter(efb => efb.WithText(CurrentQuestion.GetHint())).Build()) .ConfigureAwait(false); } - catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound || ex.StatusCode == System.Net.HttpStatusCode.Forbidden) + catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.NotFound || ex.HttpCode == System.Net.HttpStatusCode.Forbidden) { break; } diff --git a/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs b/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs index 36829953..3fc7a34b 100644 --- a/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/StreamNotificationCommands.cs @@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Searches var server = NadekoBot.Client.GetGuild(fs.GuildId); if (server == null) return; - var channel = await server.GetTextChannelAsync(fs.ChannelId); + var channel = server.GetTextChannel(fs.ChannelId); if (channel == null) return; try diff --git a/src/NadekoBot/Modules/Utility/Commands/MessageRepeater.cs b/src/NadekoBot/Modules/Utility/Commands/MessageRepeater.cs index 619b71fa..b6efe2fc 100644 --- a/src/NadekoBot/Modules/Utility/Commands/MessageRepeater.cs +++ b/src/NadekoBot/Modules/Utility/Commands/MessageRepeater.cs @@ -40,7 +40,7 @@ namespace NadekoBot.Modules.Utility { _log = LogManager.GetCurrentClassLogger(); this.Repeater = repeater; - this.Channel = channel ?? NadekoBot.Client.GetGuild(repeater.GuildId)?.GetTextChannelAsync(repeater.ChannelId).GetAwaiter().GetResult(); + this.Channel = channel ?? NadekoBot.Client.GetGuild(repeater.GuildId)?.GetTextChannel(repeater.ChannelId); if (Channel == null) return; Task.Run(Run); @@ -69,12 +69,12 @@ namespace NadekoBot.Modules.Utility { oldMsg = await Channel.SendMessageAsync(toSend).ConfigureAwait(false); } - catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.Forbidden) + catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.Forbidden) { _log.Warn("Missing permissions. Repeater stopped. ChannelId : {0}", Channel?.Id); return; } - catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound) + catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.NotFound) { _log.Warn("Channel not found. Repeater stopped. ChannelId : {0}", Channel?.Id); return; diff --git a/src/NadekoBot/Modules/Utility/Commands/Remind.cs b/src/NadekoBot/Modules/Utility/Commands/Remind.cs index 7d371c22..94521dd6 100644 --- a/src/NadekoBot/Modules/Utility/Commands/Remind.cs +++ b/src/NadekoBot/Modules/Utility/Commands/Remind.cs @@ -68,9 +68,7 @@ namespace NadekoBot.Modules.Utility } else { - var t = NadekoBot.Client.GetGuild(r.ServerId)?.GetTextChannelAsync(r.ChannelId).ConfigureAwait(false); - if (t != null) - ch = await t.Value; + ch = NadekoBot.Client.GetGuild(r.ServerId)?.GetTextChannel(r.ChannelId); } if (ch == null) return; diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 2e4d3daf..02c60720 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -75,7 +75,8 @@ namespace NadekoBot //initialize Services CommandService = new CommandService(new CommandServiceConfig() { - CaseSensitiveCommands = false + CaseSensitiveCommands = false, + DefaultRunMode = RunMode.Sync }); Google = new GoogleApiService(); CommandHandler = new CommandHandler(Client, CommandService);