Added IMessage.Tags

This commit is contained in:
RogueException
2016-10-06 09:06:04 -03:00
parent abd315ed21
commit 090a1bc736
33 changed files with 478 additions and 421 deletions

View File

@@ -63,13 +63,13 @@ namespace Discord.Rest
//Messages
public static async Task<RestMessage> GetMessageAsync(IChannel channel, BaseDiscordClient client,
ulong id, RequestOptions options)
ulong id, IGuild guild, RequestOptions options)
{
var model = await client.ApiClient.GetChannelMessageAsync(channel.Id, id, options).ConfigureAwait(false);
return RestMessage.Create(client, model);
return RestMessage.Create(client, guild, model);
}
public static IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IChannel channel, BaseDiscordClient client,
ulong? fromMessageId, Direction dir, int limit, RequestOptions options)
ulong? fromMessageId, Direction dir, int limit, IGuild guild, RequestOptions options)
{
//TODO: Test this with Around direction
return new PagedAsyncEnumerable<RestMessage>(
@@ -84,7 +84,7 @@ namespace Discord.Rest
if (info.Position != null)
args.RelativeMessageId = info.Position.Value;
var models = await client.ApiClient.GetChannelMessagesAsync(channel.Id, args, options);
return models.Select(x => RestMessage.Create(client, x)).ToImmutableArray(); ;
return models.Select(x => RestMessage.Create(client, guild, x)).ToImmutableArray(); ;
},
nextPage: (info, lastPage) =>
{
@@ -99,34 +99,34 @@ namespace Discord.Rest
count: limit
);
}
public static async Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(IChannel channel, BaseDiscordClient client,
RequestOptions options)
public static async Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(IChannel channel, BaseDiscordClient client,
IGuild guild, RequestOptions options)
{
var models = await client.ApiClient.GetPinsAsync(channel.Id, options).ConfigureAwait(false);
return models.Select(x => RestMessage.Create(client, x)).ToImmutableArray();
return models.Select(x => RestMessage.Create(client, guild, x)).ToImmutableArray();
}
public static async Task<RestUserMessage> SendMessageAsync(IChannel channel, BaseDiscordClient client,
string text, bool isTTS, RequestOptions options)
string text, bool isTTS, IGuild guild, RequestOptions options)
{
var args = new CreateMessageParams(text) { IsTTS = isTTS };
var model = await client.ApiClient.CreateMessageAsync(channel.Id, args, options).ConfigureAwait(false);
return RestUserMessage.Create(client, model);
return RestUserMessage.Create(client, guild, model);
}
public static Task<RestUserMessage> SendFileAsync(IChannel channel, BaseDiscordClient client,
string filePath, string text, bool isTTS, RequestOptions options)
string filePath, string text, bool isTTS, IGuild guild, RequestOptions options)
{
string filename = Path.GetFileName(filePath);
using (var file = File.OpenRead(filePath))
return SendFileAsync(channel, client, file, filename, text, isTTS, options);
return SendFileAsync(channel, client, file, filename, text, isTTS, guild, options);
}
public static async Task<RestUserMessage> SendFileAsync(IChannel channel, BaseDiscordClient client,
Stream stream, string filename, string text, bool isTTS, RequestOptions options)
Stream stream, string filename, string text, bool isTTS, IGuild guild, RequestOptions options)
{
var args = new UploadFileParams(stream) { Filename = filename, Content = text, IsTTS = isTTS };
var model = await client.ApiClient.UploadFileAsync(channel.Id, args, options).ConfigureAwait(false);
return RestUserMessage.Create(client, model);
return RestUserMessage.Create(client, guild, model);
}
public static async Task DeleteMessagesAsync(IChannel channel, BaseDiscordClient client,

View File

@@ -43,7 +43,9 @@ namespace Discord.Rest
public abstract Task UpdateAsync(RequestOptions options = null);
//IChannel
//IChannel
string IChannel.Name => null;
Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult<IUser>(null); //Overriden
IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)

View File

@@ -53,22 +53,22 @@ namespace Discord.Rest
}
public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null)
=> ChannelHelper.GetMessageAsync(this, Discord, id, options);
=> ChannelHelper.GetMessageAsync(this, Discord, id, null, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options);
=> ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, null, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options);
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, null, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options);
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, null, options);
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options);
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, options);
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options);
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options);
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, options);
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, null, options);
public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null)
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messages, options);
@@ -131,7 +131,9 @@ namespace Discord.Rest
IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options);
//IChannel
//IChannel
string IChannel.Name => $"@{Recipient}";
Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult<IUser>(GetUser(id));
IAsyncEnumerable<IReadOnlyCollection<IUser>> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)

View File

@@ -66,22 +66,22 @@ namespace Discord.Rest
}
public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null)
=> ChannelHelper.GetMessageAsync(this, Discord, id, options);
=> ChannelHelper.GetMessageAsync(this, Discord, id, null, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options);
=> ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, null, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options);
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, null, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options);
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, null, options);
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options);
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, options);
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options);
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options);
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, options);
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, null, options);
public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null)
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messages, options);

View File

@@ -43,22 +43,22 @@ namespace Discord.Rest
=> ChannelHelper.GetUsersAsync(this, Guild, Discord, null, null, options);
public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null)
=> ChannelHelper.GetMessageAsync(this, Discord, id, options);
=> ChannelHelper.GetMessageAsync(this, Discord, id, null, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options);
=> ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, null, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options);
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, null, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options);
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, null, options);
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options);
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, options);
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options);
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options);
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, options);
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, null, options);
public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null)
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messages, options);

View File

@@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@@ -11,8 +10,6 @@ namespace Discord.Rest
{
internal static class MessageHelper
{
private static readonly Regex _emojiRegex = new Regex(@"<:(.+?):(\d+?)>", RegexOptions.Compiled);
public static async Task ModifyAsync(IMessage msg, BaseDiscordClient client, Action<ModifyMessageParams> func,
RequestOptions options)
{
@@ -37,17 +34,94 @@ namespace Discord.Rest
await client.ApiClient.RemovePinAsync(msg.ChannelId, msg.Id, options);
}
public static ImmutableArray<Emoji> GetEmojis(string text)
public static ImmutableArray<ITag> ParseTags(string text, IMessageChannel channel, IGuild guild, ImmutableArray<IUser> userMentions)
{
var matches = _emojiRegex.Matches(text);
var builder = ImmutableArray.CreateBuilder<Emoji>(matches.Count);
foreach (var match in matches.OfType<Match>())
var tags = new SortedList<int, ITag>();
int index = 0;
while (true)
{
index = text.IndexOf('<', index);
if (index == -1) break;
int endIndex = text.IndexOf('>', index + 1);
if (endIndex == -1) break;
string content = text.Substring(index, endIndex - index + 1);
ulong id;
if (ulong.TryParse(match.Groups[2].Value, NumberStyles.None, CultureInfo.InvariantCulture, out id))
builder.Add(new Emoji(id, match.Groups[1].Value, match.Index, match.Length));
if (MentionUtils.TryParseUser(content, out id))
{
IUser mentionedUser = null;
foreach (var mention in userMentions)
{
if (mention.Id == id)
{
mentionedUser = channel?.GetUserAsync(id, CacheMode.CacheOnly).GetAwaiter().GetResult();
if (mentionedUser == null)
mentionedUser = mention;
break;
}
}
tags.Add(index, new Tag<IUser>(TagType.UserMention, index, content.Length, id, mentionedUser));
}
else if (MentionUtils.TryParseChannel(content, out id))
{
IChannel mentionedChannel = null;
if (guild != null)
mentionedChannel = guild.GetChannelAsync(id, CacheMode.CacheOnly).GetAwaiter().GetResult();
tags.Add(index, new Tag<IChannel>(TagType.ChannelMention, index, content.Length, id, mentionedChannel));
}
else if (MentionUtils.TryParseRole(content, out id))
{
IRole mentionedRole = null;
if (guild != null)
mentionedRole = guild.GetRole(id);
tags.Add(index, new Tag<IRole>(TagType.RoleMention, index, content.Length, id, mentionedRole));
}
else
{
Emoji emoji;
if (Emoji.TryParse(content, out emoji))
tags.Add(index, new Tag<Emoji>(TagType.Emoji, index, content.Length, id, emoji));
}
index = endIndex + 1;
}
return builder.ToImmutable();
index = 0;
while (true)
{
index = text.IndexOf("@everyone", index);
if (index == -1) break;
tags.Add(index, new Tag<object>(TagType.EveryoneMention, index, "@everyone".Length, 0, null));
index++;
}
index = 0;
while (true)
{
index = text.IndexOf("@here", index);
if (index == -1) break;
tags.Add(index, new Tag<object>(TagType.HereMention, index, "@here".Length, 0, null));
index++;
}
return tags.Values.ToImmutableArray();
}
public static ImmutableArray<ulong> FilterTagsByKey(TagType type, ImmutableArray<ITag> tags)
{
return tags
.Where(x => x.Type == type)
.Select(x => x.Key)
.ToImmutableArray();
}
public static ImmutableArray<T> FilterTagsByValue<T>(TagType type, ImmutableArray<ITag> tags)
{
return tags
.Where(x => x.Type == type)
.Select(x => (T)x.Value)
.Where(x => x != null)
.ToImmutableArray();
}
}
}

View File

@@ -8,6 +8,7 @@ namespace Discord.Rest
{
public abstract class RestMessage : RestEntity<ulong>, IMessage, IUpdateable
{
internal readonly IGuild _guild;
private long _timestampTicks;
public ulong ChannelId { get; }
@@ -21,25 +22,26 @@ namespace Discord.Rest
public virtual DateTimeOffset? EditedTimestamp => null;
public virtual IReadOnlyCollection<Attachment> Attachments => ImmutableArray.Create<Attachment>();
public virtual IReadOnlyCollection<Embed> Embeds => ImmutableArray.Create<Embed>();
public virtual IReadOnlyCollection<Emoji> Emojis => ImmutableArray.Create<Emoji>();
public virtual IReadOnlyCollection<ulong> MentionedChannelIds => ImmutableArray.Create<ulong>();
public virtual IReadOnlyCollection<RestRole> MentionedRoles => ImmutableArray.Create<RestRole>();
public virtual IReadOnlyCollection<RestUser> MentionedUsers => ImmutableArray.Create<RestUser>();
public virtual IReadOnlyCollection<ITag> Tags => ImmutableArray.Create<ITag>();
public DateTimeOffset Timestamp => DateTimeUtils.FromTicks(_timestampTicks);
internal RestMessage(BaseDiscordClient discord, ulong id, ulong channelId, RestUser author)
internal RestMessage(BaseDiscordClient discord, ulong id, ulong channelId, RestUser author, IGuild guild)
: base(discord, id)
{
ChannelId = channelId;
Author = author;
_guild = guild;
}
internal static RestMessage Create(BaseDiscordClient discord, Model model)
internal static RestMessage Create(BaseDiscordClient discord, IGuild guild, Model model)
{
if (model.Type == MessageType.Default)
return RestUserMessage.Create(discord, model);
return RestUserMessage.Create(discord, guild, model);
else
return RestSystemMessage.Create(discord, model);
return RestSystemMessage.Create(discord, guild, model);
}
internal virtual void Update(Model model)
{

View File

@@ -8,13 +8,13 @@ namespace Discord.Rest
{
public MessageType Type { get; private set; }
internal RestSystemMessage(BaseDiscordClient discord, ulong id, ulong channelId, RestUser author)
: base(discord, id, channelId, author)
internal RestSystemMessage(BaseDiscordClient discord, ulong id, ulong channelId, RestUser author, IGuild guild)
: base(discord, id, channelId, author, guild)
{
}
internal new static RestSystemMessage Create(BaseDiscordClient discord, Model model)
internal new static RestSystemMessage Create(BaseDiscordClient discord, IGuild guild, Model model)
{
var entity = new RestSystemMessage(discord, model.Id, model.ChannelId, RestUser.Create(discord, model.Author.Value));
var entity = new RestSystemMessage(discord, model.Id, model.ChannelId, RestUser.Create(discord, model.Author.Value), guild);
entity.Update(model);
return entity;
}

View File

@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Model = Discord.API.Message;
@@ -15,10 +16,7 @@ namespace Discord.Rest
private long? _editedTimestampTicks;
private ImmutableArray<Attachment> _attachments;
private ImmutableArray<Embed> _embeds;
private ImmutableArray<Emoji> _emojis;
private ImmutableArray<ulong> _mentionedChannelIds;
private ImmutableArray<RestRole> _mentionedRoles;
private ImmutableArray<RestUser> _mentionedUsers;
private ImmutableArray<ITag> _tags;
public ulong? WebhookId { get; private set; }
@@ -28,18 +26,18 @@ namespace Discord.Rest
public override DateTimeOffset? EditedTimestamp => DateTimeUtils.FromTicks(_editedTimestampTicks);
public override IReadOnlyCollection<Attachment> Attachments => _attachments;
public override IReadOnlyCollection<Embed> Embeds => _embeds;
public override IReadOnlyCollection<Emoji> Emojis => _emojis;
public override IReadOnlyCollection<ulong> MentionedChannelIds => _mentionedChannelIds;
public override IReadOnlyCollection<RestRole> MentionedRoles => _mentionedRoles;
public override IReadOnlyCollection<RestUser> MentionedUsers => _mentionedUsers;
public override IReadOnlyCollection<ulong> MentionedChannelIds => MessageHelper.FilterTagsByKey(TagType.ChannelMention, _tags);
public override IReadOnlyCollection<RestRole> MentionedRoles => MessageHelper.FilterTagsByValue<RestRole>(TagType.RoleMention, _tags);
public override IReadOnlyCollection<RestUser> MentionedUsers => MessageHelper.FilterTagsByValue<RestUser>(TagType.UserMention, _tags);
public override IReadOnlyCollection<ITag> Tags => _tags;
internal RestUserMessage(BaseDiscordClient discord, ulong id, ulong channelId, RestUser author)
: base(discord, id, channelId, author)
internal RestUserMessage(BaseDiscordClient discord, ulong id, ulong channelId, RestUser author, IGuild guild)
: base(discord, id, channelId, author, guild)
{
}
internal new static RestUserMessage Create(BaseDiscordClient discord, Model model)
internal new static RestUserMessage Create(BaseDiscordClient discord, IGuild guild, Model model)
{
var entity = new RestUserMessage(discord, model.Id, model.ChannelId, RestUser.Create(discord, model.Author.Value));
var entity = new RestUserMessage(discord, model.Id, model.ChannelId, RestUser.Create(discord, model.Author.Value), guild);
entity.Update(model);
return entity;
}
@@ -87,13 +85,13 @@ namespace Discord.Rest
_embeds = ImmutableArray.Create<Embed>();
}
ImmutableArray<RestUser> mentions = ImmutableArray.Create<RestUser>();
ImmutableArray<IUser> mentions = ImmutableArray.Create<IUser>();
if (model.Mentions.IsSpecified)
{
var value = model.Mentions.Value;
if (value.Length > 0)
{
var newMentions = ImmutableArray.CreateBuilder<RestUser>(value.Length);
var newMentions = ImmutableArray.CreateBuilder<IUser>(value.Length);
for (int i = 0; i < value.Length; i++)
newMentions.Add(RestUser.Create(Discord, value[i]));
mentions = newMentions.ToImmutable();
@@ -103,11 +101,7 @@ namespace Discord.Rest
if (model.Content.IsSpecified)
{
var text = model.Content.Value;
_mentionedUsers = MentionUtils.GetUserMentions(text, null, mentions);
_mentionedChannelIds = MentionUtils.GetChannelMentions(text, null);
_mentionedRoles = MentionUtils.GetRoleMentions<RestRole>(text, null);
_emojis = MessageHelper.GetEmojis(text);
_tags = MessageHelper.ParseTags(text, null, _guild, mentions);
model.Content = text;
}
}
@@ -122,21 +116,9 @@ namespace Discord.Rest
public Task UnpinAsync(RequestOptions options)
=> MessageHelper.UnpinAsync(this, Discord, options);
public string Resolve(UserMentionHandling userHandling = UserMentionHandling.Name, ChannelMentionHandling channelHandling = ChannelMentionHandling.Name,
RoleMentionHandling roleHandling = RoleMentionHandling.Name, EveryoneMentionHandling everyoneHandling = EveryoneMentionHandling.Ignore)
=> Resolve(Content, userHandling, channelHandling, roleHandling, everyoneHandling);
public string Resolve(int startIndex, int length, UserMentionHandling userHandling = UserMentionHandling.Name, ChannelMentionHandling channelHandling = ChannelMentionHandling.Name,
RoleMentionHandling roleHandling = RoleMentionHandling.Name, EveryoneMentionHandling everyoneHandling = EveryoneMentionHandling.Ignore)
=> Resolve(Content.Substring(startIndex, length), userHandling, channelHandling, roleHandling, everyoneHandling);
public string Resolve(string text, UserMentionHandling userHandling, ChannelMentionHandling channelHandling,
RoleMentionHandling roleHandling, EveryoneMentionHandling everyoneHandling)
{
text = MentionUtils.ResolveUserMentions(text, null, MentionedUsers, userHandling);
text = MentionUtils.ResolveChannelMentions(text, null, channelHandling);
text = MentionUtils.ResolveRoleMentions(text, MentionedRoles, roleHandling);
text = MentionUtils.ResolveEveryoneMentions(text, everyoneHandling);
return text;
}
public string Resolve(TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name,
TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name)
=> MentionUtils.Resolve(this, userHandling, channelHandling, roleHandling, everyoneHandling, emojiHandling);
private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")})";
}