Added support for .NET Standard 1.1 and 1.2
This commit is contained in:
@@ -139,6 +139,7 @@ namespace Discord.Rest
|
||||
return RestUserMessage.Create(client, channel, client.CurrentUser, model);
|
||||
}
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
|
||||
string filePath, string text, bool isTTS, RequestOptions options)
|
||||
{
|
||||
@@ -146,6 +147,7 @@ namespace Discord.Rest
|
||||
using (var file = File.OpenRead(filePath))
|
||||
return await SendFileAsync(channel, client, file, filename, text, isTTS, options).ConfigureAwait(false);
|
||||
}
|
||||
#endif
|
||||
public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
|
||||
Stream stream, string filename, string text, bool isTTS, RequestOptions options)
|
||||
{
|
||||
|
||||
@@ -8,8 +8,10 @@ namespace Discord.Rest
|
||||
{
|
||||
/// <summary> Sends a message to this message channel. </summary>
|
||||
new Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, EmbedBuilder embed = null, RequestOptions options = null);
|
||||
#if NETSTANDARD1_3
|
||||
/// <summary> Sends a file to this text channel, with an optional caption. </summary>
|
||||
new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null);
|
||||
#endif
|
||||
/// <summary> Sends a file to this text channel, with an optional caption. </summary>
|
||||
new Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, RequestOptions options = null);
|
||||
|
||||
|
||||
@@ -65,8 +65,10 @@ namespace Discord.Rest
|
||||
|
||||
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, EmbedBuilder embed = null, RequestOptions options = null)
|
||||
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
|
||||
#if NETSTANDARD1_3
|
||||
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
|
||||
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
|
||||
#endif
|
||||
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null)
|
||||
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, options);
|
||||
|
||||
@@ -122,8 +124,10 @@ namespace Discord.Rest
|
||||
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
|
||||
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
|
||||
#endif
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
|
||||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, EmbedBuilder embed, RequestOptions options)
|
||||
|
||||
@@ -78,8 +78,10 @@ namespace Discord.Rest
|
||||
|
||||
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, EmbedBuilder embed = null, RequestOptions options = null)
|
||||
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
|
||||
#if NETSTANDARD1_3
|
||||
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
|
||||
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
|
||||
#endif
|
||||
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null)
|
||||
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, options);
|
||||
|
||||
@@ -132,8 +134,10 @@ namespace Discord.Rest
|
||||
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
|
||||
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
|
||||
#endif
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
|
||||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, EmbedBuilder embed, RequestOptions options)
|
||||
|
||||
@@ -57,8 +57,10 @@ namespace Discord.Rest
|
||||
|
||||
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, EmbedBuilder embed = null, RequestOptions options = null)
|
||||
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
|
||||
#if NETSTANDARD1_3
|
||||
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
|
||||
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
|
||||
#endif
|
||||
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null)
|
||||
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, options);
|
||||
|
||||
@@ -104,8 +106,10 @@ namespace Discord.Rest
|
||||
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
|
||||
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
|
||||
#endif
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
|
||||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, EmbedBuilder embed, RequestOptions options)
|
||||
|
||||
@@ -35,8 +35,10 @@ namespace Discord.Rest
|
||||
|
||||
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS, EmbedBuilder embed = null, RequestOptions options = null)
|
||||
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
|
||||
#if NETSTANDARD1_3
|
||||
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options = null)
|
||||
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
|
||||
#endif
|
||||
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options = null)
|
||||
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, options);
|
||||
|
||||
@@ -82,8 +84,10 @@ namespace Discord.Rest
|
||||
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
|
||||
=> await GetPinnedMessagesAsync(options);
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(filePath, text, isTTS, options);
|
||||
#endif
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(stream, filename, text, isTTS, options);
|
||||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, EmbedBuilder embed, RequestOptions options)
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Discord.Rest
|
||||
|
||||
public static ImmutableArray<ITag> ParseTags(string text, IMessageChannel channel, IGuild guild, ImmutableArray<IUser> userMentions)
|
||||
{
|
||||
var tags = new SortedList<int, ITag>();
|
||||
var tags = ImmutableArray.CreateBuilder<ITag>();
|
||||
|
||||
int index = 0;
|
||||
while (true)
|
||||
@@ -94,27 +94,27 @@ namespace Discord.Rest
|
||||
break;
|
||||
}
|
||||
}
|
||||
tags.Add(index, new Tag<IUser>(TagType.UserMention, index, content.Length, id, mentionedUser));
|
||||
tags.Add(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));
|
||||
tags.Add(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));
|
||||
tags.Add(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));
|
||||
tags.Add(new Tag<Emoji>(TagType.Emoji, index, content.Length, id, emoji));
|
||||
}
|
||||
index = endIndex + 1;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ namespace Discord.Rest
|
||||
index = text.IndexOf("@everyone", index);
|
||||
if (index == -1) break;
|
||||
|
||||
tags.Add(index, new Tag<object>(TagType.EveryoneMention, index, "@everyone".Length, 0, null));
|
||||
tags.Add(new Tag<object>(TagType.EveryoneMention, index, "@everyone".Length, 0, null));
|
||||
index++;
|
||||
}
|
||||
|
||||
@@ -135,11 +135,11 @@ namespace Discord.Rest
|
||||
index = text.IndexOf("@here", index);
|
||||
if (index == -1) break;
|
||||
|
||||
tags.Add(index, new Tag<object>(TagType.HereMention, index, "@here".Length, 0, null));
|
||||
tags.Add(new Tag<object>(TagType.HereMention, index, "@here".Length, 0, null));
|
||||
index++;
|
||||
}
|
||||
|
||||
return tags.Values.ToImmutableArray();
|
||||
return tags.ToImmutable();
|
||||
}
|
||||
public static ImmutableArray<ulong> FilterTagsByKey(TagType type, ImmutableArray<ITag> tags)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user