|
|
@@ -6,7 +6,6 @@ using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Model = Discord.API.Channel; |
|
|
|
using UserModel = Discord.API.User; |
|
|
|
|
|
|
|
namespace Discord.Rest |
|
|
|
{ |
|
|
@@ -130,7 +129,7 @@ namespace Discord.Rest |
|
|
|
var model = await client.ApiClient.GetChannelMessageAsync(channel.Id, id, options).ConfigureAwait(false); |
|
|
|
if (model == null) |
|
|
|
return null; |
|
|
|
var author = GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); |
|
|
|
var author = MessageHelper.GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); |
|
|
|
return RestMessage.Create(client, channel, author, model); |
|
|
|
} |
|
|
|
public static IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessageChannel channel, BaseDiscordClient client, |
|
|
@@ -165,7 +164,7 @@ namespace Discord.Rest |
|
|
|
var builder = ImmutableArray.CreateBuilder<RestMessage>(); |
|
|
|
foreach (var model in models) |
|
|
|
{ |
|
|
|
var author = GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); |
|
|
|
var author = MessageHelper.GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); |
|
|
|
builder.Add(RestMessage.Create(client, channel, author, model)); |
|
|
|
} |
|
|
|
return builder.ToImmutable(); |
|
|
@@ -193,7 +192,7 @@ namespace Discord.Rest |
|
|
|
var builder = ImmutableArray.CreateBuilder<RestMessage>(); |
|
|
|
foreach (var model in models) |
|
|
|
{ |
|
|
|
var author = GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); |
|
|
|
var author = MessageHelper.GetAuthor(client, guild, model.Author.Value, model.WebhookId.ToNullable()); |
|
|
|
builder.Add(RestMessage.Create(client, channel, author, model)); |
|
|
|
} |
|
|
|
return builder.ToImmutable(); |
|
|
@@ -450,16 +449,5 @@ namespace Discord.Rest |
|
|
|
}; |
|
|
|
await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
//Helpers |
|
|
|
private static IUser GetAuthor(BaseDiscordClient client, IGuild guild, UserModel model, ulong? webhookId) |
|
|
|
{ |
|
|
|
IUser author = null; |
|
|
|
if (guild != null) |
|
|
|
author = guild.GetUserAsync(model.Id, CacheMode.CacheOnly).Result; |
|
|
|
if (author == null) |
|
|
|
author = RestUser.Create(client, guild, model, webhookId); |
|
|
|
return author; |
|
|
|
} |
|
|
|
} |
|
|
|
} |