Exposed RequestOptions

This commit is contained in:
RogueException
2016-10-06 02:44:41 -03:00
parent aa7d9ad414
commit f41df1f966
54 changed files with 793 additions and 766 deletions

View File

@@ -34,95 +34,95 @@ namespace Discord.Rest
}
public Task ModifyAsync(Action<ModifyTextChannelParams> func)
=> ChannelHelper.ModifyAsync(this, Discord, func);
public Task ModifyAsync(Action<ModifyTextChannelParams> func, RequestOptions options = null)
=> ChannelHelper.ModifyAsync(this, Discord, func, options);
public Task<RestGuildUser> GetUserAsync(ulong id)
=> ChannelHelper.GetUserAsync(this, Guild, Discord, id);
public IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync()
=> ChannelHelper.GetUsersAsync(this, Guild, Discord);
public Task<RestGuildUser> GetUserAsync(ulong id, RequestOptions options = null)
=> ChannelHelper.GetUserAsync(this, Guild, Discord, id, options);
public IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync(RequestOptions options = null)
=> ChannelHelper.GetUsersAsync(this, Guild, Discord, null, null, options);
public Task<RestMessage> GetMessageAsync(ulong id)
=> ChannelHelper.GetMessageAsync(this, Discord, id);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch)
=> ChannelHelper.GetMessagesAsync(this, Discord, limit: limit);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
=> ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit);
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync()
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord);
public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null)
=> ChannelHelper.GetMessageAsync(this, Discord, id, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
=> ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, 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);
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);
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS);
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS);
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS);
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, options);
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, 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);
public Task DeleteMessagesAsync(IEnumerable<IMessage> messages)
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messages);
public Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null)
=> ChannelHelper.DeleteMessagesAsync(this, Discord, messages, options);
public IDisposable EnterTypingState()
=> ChannelHelper.EnterTypingState(this, Discord);
public IDisposable EnterTypingState(RequestOptions options = null)
=> ChannelHelper.EnterTypingState(this, Discord, options);
private string DebuggerDisplay => $"{Name} ({Id}, Text)";
//IGuildChannel
async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode)
async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return await GetUserAsync(id);
return await GetUserAsync(id, options);
else
return null;
}
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode)
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return GetUsersAsync();
return GetUsersAsync(options);
else
return AsyncEnumerable.Empty<IReadOnlyCollection<IGuildUser>>(); //Overriden
}
//IMessageChannel
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode)
async Task<IMessage> IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return await GetMessageAsync(id);
return await GetMessageAsync(id, options);
else
return null;
}
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode)
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return GetMessagesAsync(limit);
return GetMessagesAsync(limit, options);
else
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
}
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode)
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return GetMessagesAsync(fromMessageId, dir, limit);
return GetMessagesAsync(fromMessageId, dir, limit, options);
else
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
}
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode)
IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return GetMessagesAsync(fromMessage, dir, limit);
return GetMessagesAsync(fromMessage, dir, limit, options);
else
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
}
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync()
=> await GetPinnedMessagesAsync();
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options);
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS)
=> await SendFileAsync(filePath, text, isTTS);
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS)
=> await SendFileAsync(stream, filename, text, isTTS);
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS)
=> await SendMessageAsync(text, isTTS);
IDisposable IMessageChannel.EnterTypingState()
=> EnterTypingState();
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options);
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, RequestOptions options)
=> await SendMessageAsync(text, isTTS, options);
IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
=> EnterTypingState(options);
}
}