diff --git a/src/Discord.Net.Commands/Command.cs b/src/Discord.Net.Commands/Command.cs index b0dd4733c..f89be8b90 100644 --- a/src/Discord.Net.Commands/Command.cs +++ b/src/Discord.Net.Commands/Command.cs @@ -14,11 +14,11 @@ namespace Discord.Commands private readonly Func, Task> _action; public MethodInfo Source { get; } + public Module Module { get; } public string Name { get; } public string Description { get; } public string Summary { get; } public string Text { get; } - public Module Module { get; } public IReadOnlyList Parameters { get; } public IReadOnlyList Preconditions { get; } diff --git a/src/Discord.Net.Commands/CommandParser.cs b/src/Discord.Net.Commands/CommandParser.cs index cceaa4a65..ad43758e3 100644 --- a/src/Discord.Net.Commands/CommandParser.cs +++ b/src/Discord.Net.Commands/CommandParser.cs @@ -2,7 +2,6 @@ using System.Text; using System.Threading.Tasks; using System.Collections.Generic; -using System.Linq; using System; namespace Discord.Commands diff --git a/src/Discord.Net/Rest/Entities/Messages/Message.cs b/src/Discord.Net/Rest/Entities/Messages/Message.cs index 14c4051cd..ac06a61f8 100644 --- a/src/Discord.Net/Rest/Entities/Messages/Message.cs +++ b/src/Discord.Net/Rest/Entities/Messages/Message.cs @@ -171,14 +171,10 @@ namespace Discord private string Resolve(string text, UserMentionHandling userHandling, ChannelMentionHandling channelHandling, RoleMentionHandling roleHandling, EveryoneMentionHandling everyoneHandling) { - var guild = (Channel as IGuildChannel)?.Guild; text = MentionUtils.ResolveUserMentions(text, Channel, MentionedUsers, userHandling); - if (guild != null) - { - text = MentionUtils.ResolveChannelMentions(text, guild, channelHandling); - text = MentionUtils.ResolveRoleMentions(text, guild, MentionedRoles, roleHandling); - text = MentionUtils.ResolveEveryoneMentions(text, everyoneHandling); - } + text = MentionUtils.ResolveChannelMentions(text, (Channel as IGuildChannel)?.Guild, channelHandling); + text = MentionUtils.ResolveRoleMentions(text, MentionedRoles, roleHandling); + text = MentionUtils.ResolveEveryoneMentions(text, everyoneHandling); return text; } diff --git a/src/Discord.Net/Utilities/MentionUtils.cs b/src/Discord.Net/Utilities/MentionUtils.cs index 3f8fefa30..2c32b5ea9 100644 --- a/src/Discord.Net/Utilities/MentionUtils.cs +++ b/src/Discord.Net/Utilities/MentionUtils.cs @@ -1,4 +1,5 @@ -using System; +using Discord.WebSocket; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Globalization; @@ -215,7 +216,7 @@ namespace Discord return ""; case ChannelMentionHandling.Name: IGuildChannel channel = null; - channel = guild.GetChannelAsync(id).GetAwaiter().GetResult(); + channel = guild?.GetChannel(id); if (channel != null) return $"#{channel.Name}"; else @@ -227,7 +228,7 @@ namespace Discord } return text; } - internal static string ResolveRoleMentions(string text, IGuild guild, IReadOnlyCollection mentions, RoleMentionHandling mode) + internal static string ResolveRoleMentions(string text, IReadOnlyCollection mentions, RoleMentionHandling mode) { if (mode == RoleMentionHandling.Ignore) return text;