Updated discord.net

This commit is contained in:
Kwoth 2017-01-29 00:38:09 +01:00
parent c4ca121c02
commit 24b8763ca8
11 changed files with 21 additions and 30 deletions

@ -1 +1 @@
Subproject commit 7c0cce6d35b04d883cf5ec2d775b051e4bc8739f Subproject commit 05e7377142b8d8ccfabe0236dd8d2c40fb8d4bbf

View File

@ -25,7 +25,6 @@ namespace NadekoBot.Modules.Administration
static AutoAssignRoleCommands() static AutoAssignRoleCommands()
{ {
_log = LogManager.GetCurrentClassLogger(); _log = LogManager.GetCurrentClassLogger();
var sw = Stopwatch.StartNew();
AutoAssignedRoles = new ConcurrentDictionary<ulong, ulong>(NadekoBot.AllGuildConfigs.Where(x => x.AutoAssignRoleId != 0) AutoAssignedRoles = new ConcurrentDictionary<ulong, ulong>(NadekoBot.AllGuildConfigs.Where(x => x.AutoAssignRoleId != 0)
.ToDictionary(k => k.GuildId, v => v.AutoAssignRoleId)); .ToDictionary(k => k.GuildId, v => v.AutoAssignRoleId));
@ -46,9 +45,6 @@ namespace NadekoBot.Modules.Administration
} }
catch (Exception ex) { _log.Warn(ex); } catch (Exception ex) { _log.Warn(ex); }
}; };
sw.Stop();
_log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s");
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]

View File

@ -132,7 +132,7 @@ namespace NadekoBot.Modules.Administration
if (ids[1].ToUpperInvariant().StartsWith("C:")) if (ids[1].ToUpperInvariant().StartsWith("C:"))
{ {
var cid = ulong.Parse(ids[1].Substring(2)); 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) if (ch == null)
{ {
return; return;
@ -159,9 +159,7 @@ namespace NadekoBot.Modules.Administration
[OwnerOnly] [OwnerOnly]
public async Task Announce([Remainder] string message) public async Task Announce([Remainder] string message)
{ {
var channels = await Task.WhenAll(NadekoBot.Client.GetGuilds().Select(g => var channels = NadekoBot.Client.GetGuilds().Select(g => g.DefaultChannel).ToArray();
g.GetDefaultChannelAsync()
)).ConfigureAwait(false);
if (channels == null) if (channels == null)
return; return;
await Task.WhenAll(channels.Where(c => c != null).Select(c => c.SendConfirmAsync($"🆕 Message from {Context.User} `[Bot Owner]`:", message))) await Task.WhenAll(channels.Where(c => c != null).Select(c => c.SendConfirmAsync($"🆕 Message from {Context.User} `[Bot Owner]`:", message)))

View File

@ -57,7 +57,7 @@ namespace NadekoBot.Modules.Administration
{ {
try try
{ {
await (await guild.GetOwnerAsync()).SendErrorAsync( await guild.Owner.SendErrorAsync(
"⚠️ I don't have **manage server** and/or **manage channels** permission," + "⚠️ I don't have **manage server** and/or **manage channels** permission," +
$" so I cannot run `voice+text` on **{guild.Name}** server.").ConfigureAwait(false); $" so I cannot run `voice+text` on **{guild.Name}** server.").ConfigureAwait(false);
} }
@ -75,16 +75,16 @@ namespace NadekoBot.Modules.Administration
var beforeVch = before.VoiceChannel; var beforeVch = before.VoiceChannel;
if (beforeVch != null) 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) if (textChannel != null)
await textChannel.AddPermissionOverwriteAsync(user, await textChannel.AddPermissionOverwriteAsync(user,
new OverwritePermissions(readMessages: PermValue.Deny, new OverwritePermissions(readMessages: PermValue.Deny,
sendMessages: PermValue.Deny)).ConfigureAwait(false); sendMessages: PermValue.Deny)).ConfigureAwait(false);
} }
var afterVch = after.VoiceChannel; 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()) .Where(t => t.Name == GetChannelName(afterVch.Name).ToLowerInvariant())
.FirstOrDefault(); .FirstOrDefault();
if (textChannel == null) if (textChannel == null)

View File

@ -37,9 +37,7 @@ namespace NadekoBot.Modules.ClashOfClans
.Select(cw => .Select(cw =>
{ {
cw.Channel = NadekoBot.Client.GetGuild(cw.GuildId) cw.Channel = NadekoBot.Client.GetGuild(cw.GuildId)
?.GetTextChannelAsync(cw.ChannelId) .GetTextChannel(cw.ChannelId);
.GetAwaiter()
.GetResult();
return cw; return cw;
}) })
.Where(cw => cw.Channel != null) .Where(cw => cw.Channel != null)
@ -322,7 +320,7 @@ namespace NadekoBot.Modules.ClashOfClans
public static async Task<ClashWar> CreateWar(string enemyClan, int size, ulong serverId, ulong channelId) public static async Task<ClashWar> 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()) using (var uow = DbHandler.UnitOfWork())
{ {
var cw = new ClashWar var cw = new ClashWar

View File

@ -59,7 +59,7 @@ namespace NadekoBot.Modules.Gambling
catch catch
{ {
try { await msg.DeleteAsync().ConfigureAwait(false); } try { await msg.DeleteAsync().ConfigureAwait(false); }
catch { } catch { return; }
} }
} }
using (msg.OnReaction(async (r) => using (msg.OnReaction(async (r) =>

View File

@ -76,9 +76,9 @@ namespace NadekoBot.Modules.Games.Trivia
questionMessage = await channel.EmbedAsync(questionEmbed).ConfigureAwait(false); questionMessage = await channel.EmbedAsync(questionEmbed).ConfigureAwait(false);
} }
catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound || catch (HttpException ex) when (ex.HttpCode == System.Net.HttpStatusCode.NotFound ||
ex.StatusCode == System.Net.HttpStatusCode.Forbidden || ex.HttpCode == System.Net.HttpStatusCode.Forbidden ||
ex.StatusCode == System.Net.HttpStatusCode.BadRequest) ex.HttpCode == System.Net.HttpStatusCode.BadRequest)
{ {
return; return;
} }
@ -106,7 +106,7 @@ namespace NadekoBot.Modules.Games.Trivia
await questionMessage.ModifyAsync(m => m.Embed = questionEmbed.WithFooter(efb => efb.WithText(CurrentQuestion.GetHint())).Build()) await questionMessage.ModifyAsync(m => m.Embed = questionEmbed.WithFooter(efb => efb.WithText(CurrentQuestion.GetHint())).Build())
.ConfigureAwait(false); .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; break;
} }

View File

@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Searches
var server = NadekoBot.Client.GetGuild(fs.GuildId); var server = NadekoBot.Client.GetGuild(fs.GuildId);
if (server == null) if (server == null)
return; return;
var channel = await server.GetTextChannelAsync(fs.ChannelId); var channel = server.GetTextChannel(fs.ChannelId);
if (channel == null) if (channel == null)
return; return;
try try

View File

@ -40,7 +40,7 @@ namespace NadekoBot.Modules.Utility
{ {
_log = LogManager.GetCurrentClassLogger(); _log = LogManager.GetCurrentClassLogger();
this.Repeater = repeater; 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) if (Channel == null)
return; return;
Task.Run(Run); Task.Run(Run);
@ -69,12 +69,12 @@ namespace NadekoBot.Modules.Utility
{ {
oldMsg = await Channel.SendMessageAsync(toSend).ConfigureAwait(false); 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); _log.Warn("Missing permissions. Repeater stopped. ChannelId : {0}", Channel?.Id);
return; 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); _log.Warn("Channel not found. Repeater stopped. ChannelId : {0}", Channel?.Id);
return; return;

View File

@ -68,9 +68,7 @@ namespace NadekoBot.Modules.Utility
} }
else else
{ {
var t = NadekoBot.Client.GetGuild(r.ServerId)?.GetTextChannelAsync(r.ChannelId).ConfigureAwait(false); ch = NadekoBot.Client.GetGuild(r.ServerId)?.GetTextChannel(r.ChannelId);
if (t != null)
ch = await t.Value;
} }
if (ch == null) if (ch == null)
return; return;

View File

@ -75,7 +75,8 @@ namespace NadekoBot
//initialize Services //initialize Services
CommandService = new CommandService(new CommandServiceConfig() { CommandService = new CommandService(new CommandServiceConfig() {
CaseSensitiveCommands = false CaseSensitiveCommands = false,
DefaultRunMode = RunMode.Sync
}); });
Google = new GoogleApiService(); Google = new GoogleApiService();
CommandHandler = new CommandHandler(Client, CommandService); CommandHandler = new CommandHandler(Client, CommandService);