Browse Source

Remove guild check from Message.Resolve

pull/195/head
RogueException 8 years ago
parent
commit
fc17aa3ea0
4 changed files with 8 additions and 12 deletions
  1. +1
    -1
      src/Discord.Net.Commands/Command.cs
  2. +0
    -1
      src/Discord.Net.Commands/CommandParser.cs
  3. +3
    -7
      src/Discord.Net/Rest/Entities/Messages/Message.cs
  4. +4
    -3
      src/Discord.Net/Utilities/MentionUtils.cs

+ 1
- 1
src/Discord.Net.Commands/Command.cs View File

@@ -14,11 +14,11 @@ namespace Discord.Commands
private readonly Func<IMessage, IReadOnlyList<object>, Task> _action; private readonly Func<IMessage, IReadOnlyList<object>, Task> _action;


public MethodInfo Source { get; } public MethodInfo Source { get; }
public Module Module { get; }
public string Name { get; } public string Name { get; }
public string Description { get; } public string Description { get; }
public string Summary { get; } public string Summary { get; }
public string Text { get; } public string Text { get; }
public Module Module { get; }
public IReadOnlyList<CommandParameter> Parameters { get; } public IReadOnlyList<CommandParameter> Parameters { get; }
public IReadOnlyList<PreconditionAttribute> Preconditions { get; } public IReadOnlyList<PreconditionAttribute> Preconditions { get; }




+ 0
- 1
src/Discord.Net.Commands/CommandParser.cs View File

@@ -2,7 +2,6 @@
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System; using System;


namespace Discord.Commands namespace Discord.Commands


+ 3
- 7
src/Discord.Net/Rest/Entities/Messages/Message.cs View File

@@ -171,14 +171,10 @@ namespace Discord
private string Resolve(string text, UserMentionHandling userHandling, ChannelMentionHandling channelHandling, private string Resolve(string text, UserMentionHandling userHandling, ChannelMentionHandling channelHandling,
RoleMentionHandling roleHandling, EveryoneMentionHandling everyoneHandling) RoleMentionHandling roleHandling, EveryoneMentionHandling everyoneHandling)
{ {
var guild = (Channel as IGuildChannel)?.Guild;
text = MentionUtils.ResolveUserMentions(text, Channel, MentionedUsers, userHandling); 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; return text;
} }




+ 4
- 3
src/Discord.Net/Utilities/MentionUtils.cs View File

@@ -1,4 +1,5 @@
using System;
using Discord.WebSocket;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Globalization; using System.Globalization;
@@ -215,7 +216,7 @@ namespace Discord
return ""; return "";
case ChannelMentionHandling.Name: case ChannelMentionHandling.Name:
IGuildChannel channel = null; IGuildChannel channel = null;
channel = guild.GetChannelAsync(id).GetAwaiter().GetResult();
channel = guild?.GetChannel(id);
if (channel != null) if (channel != null)
return $"#{channel.Name}"; return $"#{channel.Name}";
else else
@@ -227,7 +228,7 @@ namespace Discord
} }
return text; return text;
} }
internal static string ResolveRoleMentions(string text, IGuild guild, IReadOnlyCollection<IRole> mentions, RoleMentionHandling mode)
internal static string ResolveRoleMentions(string text, IReadOnlyCollection<IRole> mentions, RoleMentionHandling mode)
{ {
if (mode == RoleMentionHandling.Ignore) return text; if (mode == RoleMentionHandling.Ignore) return text;


Loading…
Cancel
Save