internal static async Task <IReadOnlyList <IMessage> > InternalFetchMessagesAsync(this IRestClient client, Snowflake channelId, int limit, RetrievalDirection direction, Snowflake?startFromId, IRestRequestOptions options, CancellationToken cancellationToken) { var models = await client.ApiClient.FetchMessagesAsync(channelId, limit, direction, startFromId, options, cancellationToken).ConfigureAwait(false); return(models.ToReadOnlyList(client, (x, client) => TransientMessage.Create(client, x))); }
public static async Task <IMessage> FetchMessageAsync(this IRestClient client, Snowflake channelId, Snowflake messageId, IRestRequestOptions options = null) { try { var model = await client.ApiClient.FetchMessageAsync(channelId, messageId, options).ConfigureAwait(false); return(TransientMessage.Create(client, model)); } catch (RestApiException ex) when(ex.StatusCode == HttpResponseStatusCode.NotFound && ex.ErrorModel.Code == RestApiErrorCode.UnknownMessage) { return(null); } }