Remove guild check from Message.Resolve
This commit is contained in:
@@ -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; }
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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, (Channel as IGuildChannel)?.Guild, channelHandling);
|
||||||
{
|
text = MentionUtils.ResolveRoleMentions(text, MentionedRoles, roleHandling);
|
||||||
text = MentionUtils.ResolveChannelMentions(text, guild, channelHandling);
|
text = MentionUtils.ResolveEveryoneMentions(text, everyoneHandling);
|
||||||
text = MentionUtils.ResolveRoleMentions(text, guild, MentionedRoles, roleHandling);
|
|
||||||
text = MentionUtils.ResolveEveryoneMentions(text, everyoneHandling);
|
|
||||||
}
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user