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

@@ -6,9 +6,9 @@ namespace Discord
public interface IChannel : ISnowflakeEntity
{
/// <summary> Gets a collection of all users in this channel. </summary>
IAsyncEnumerable<IReadOnlyCollection<IUser>> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload);
IAsyncEnumerable<IReadOnlyCollection<IUser>> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Gets a user in this channel with the provided id. </summary>
Task<IUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload);
Task<IUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
}
}

View File

@@ -8,6 +8,6 @@ namespace Discord
IUser Recipient { get; }
/// <summary> Closes this private channel, removing it from your channel list. </summary>
Task CloseAsync();
Task CloseAsync(RequestOptions options = null);
}
}

View File

@@ -5,6 +5,6 @@ namespace Discord
public interface IGroupChannel : IMessageChannel, IPrivateChannel, IAudioChannel
{
/// <summary> Leaves this group. </summary>
Task LeaveAsync();
Task LeaveAsync(RequestOptions options = null);
}
}

View File

@@ -21,29 +21,29 @@ namespace Discord
/// <param name="maxAge"> The time (in seconds) until the invite expires. Set to null to never expire. </param>
/// <param name="maxUses"> The max amount of times this invite may be used. Set to null to have unlimited uses. </param>
/// <param name="isTemporary"> If true, a user accepting this invite will be kicked from the guild after closing their client. </param>
Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 1800, int? maxUses = default(int?), bool isTemporary = false);
Task<IInviteMetadata> CreateInviteAsync(int? maxAge = 1800, int? maxUses = default(int?), bool isTemporary = false, RequestOptions options = null);
/// <summary> Returns a collection of all invites to this channel. </summary>
Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync();
Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null);
/// <summary> Modifies this guild channel. </summary>
Task ModifyAsync(Action<ModifyGuildChannelParams> func);
Task ModifyAsync(Action<ModifyGuildChannelParams> func, RequestOptions options = null);
/// <summary> Gets the permission overwrite for a specific role, or null if one does not exist. </summary>
OverwritePermissions? GetPermissionOverwrite(IRole role);
/// <summary> Gets the permission overwrite for a specific user, or null if one does not exist. </summary>
OverwritePermissions? GetPermissionOverwrite(IUser user);
/// <summary> Removes the permission overwrite for the given role, if one exists. </summary>
Task RemovePermissionOverwriteAsync(IRole role);
Task RemovePermissionOverwriteAsync(IRole role, RequestOptions options = null);
/// <summary> Removes the permission overwrite for the given user, if one exists. </summary>
Task RemovePermissionOverwriteAsync(IUser user);
Task RemovePermissionOverwriteAsync(IUser user, RequestOptions options = null);
/// <summary> Adds or updates the permission overwrite for the given role. </summary>
Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions);
Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null);
/// <summary> Adds or updates the permission overwrite for the given user. </summary>
Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions);
Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null);
/// <summary> Gets a collection of all users in this channel. </summary>
new IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload);
new IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Gets a user in this channel with the provided id.</summary>
new Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload);
new Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
}
}

View File

@@ -8,26 +8,29 @@ namespace Discord
public interface IMessageChannel : IChannel
{
/// <summary> Sends a message to this message channel. </summary>
Task<IUserMessage> SendMessageAsync(string text, bool isTTS = false);
Task<IUserMessage> SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null);
/// <summary> Sends a file to this text channel, with an optional caption. </summary>
Task<IUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false);
Task<IUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null);
/// <summary> Sends a file to this text channel, with an optional caption. </summary>
Task<IUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false);
Task<IUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, RequestOptions options = null);
/// <summary> Gets a message from this message channel with the given id, or null if not found. </summary>
Task<IMessage> GetMessageAsync(ulong id, CacheMode mode = CacheMode.AllowDownload);
Task<IMessage> GetMessageAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Gets the last N messages from this message channel. </summary>
IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, CacheMode mode = CacheMode.AllowDownload);
IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch,
CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Gets a collection of messages in this channel. </summary>
IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, CacheMode mode = CacheMode.AllowDownload);
IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch,
CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Gets a collection of messages in this channel. </summary>
IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, CacheMode mode = CacheMode.AllowDownload);
IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch,
CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Gets a collection of pinned messages in this channel. </summary>
Task<IReadOnlyCollection<IMessage>> GetPinnedMessagesAsync();
Task<IReadOnlyCollection<IMessage>> GetPinnedMessagesAsync(RequestOptions options = null);
/// <summary> Bulk deletes multiple messages. </summary>
Task DeleteMessagesAsync(IEnumerable<IMessage> messages);
Task DeleteMessagesAsync(IEnumerable<IMessage> messages, RequestOptions options = null);
/// <summary> Broadcasts the "user is typing" message to all users in this channel, lasting 10 seconds.</summary>
IDisposable EnterTypingState();
IDisposable EnterTypingState(RequestOptions options = null);
}
}

View File

@@ -10,6 +10,6 @@ namespace Discord
string Topic { get; }
/// <summary> Modifies this text channel. </summary>
Task ModifyAsync(Action<ModifyTextChannelParams> func);
Task ModifyAsync(Action<ModifyTextChannelParams> func, RequestOptions options = null);
}
}

View File

@@ -13,7 +13,7 @@ namespace Discord
int UserLimit { get; }
/// <summary> Modifies this voice channel. </summary>
Task ModifyAsync(Action<ModifyVoiceChannelParams> func);
Task ModifyAsync(Action<ModifyVoiceChannelParams> func, RequestOptions options = null);
/// <summary> Connects to this voice channel. </summary>
Task<IAudioClient> ConnectAsync();
}

View File

@@ -53,56 +53,56 @@ namespace Discord
IReadOnlyCollection<IRole> Roles { get; }
/// <summary> Modifies this guild. </summary>
Task ModifyAsync(Action<ModifyGuildParams> func);
Task ModifyAsync(Action<ModifyGuildParams> func, RequestOptions options = null);
/// <summary> Modifies this guild's embed. </summary>
Task ModifyEmbedAsync(Action<ModifyGuildEmbedParams> func);
Task ModifyEmbedAsync(Action<ModifyGuildEmbedParams> func, RequestOptions options = null);
/// <summary> Bulk modifies the channels of this guild. </summary>
Task ModifyChannelsAsync(IEnumerable<ModifyGuildChannelsParams> args);
Task ModifyChannelsAsync(IEnumerable<ModifyGuildChannelsParams> args, RequestOptions options = null);
/// <summary> Bulk modifies the roles of this guild. </summary>
Task ModifyRolesAsync(IEnumerable<ModifyGuildRolesParams> args);
Task ModifyRolesAsync(IEnumerable<ModifyGuildRolesParams> args, RequestOptions options = null);
/// <summary> Leaves this guild. If you are the owner, use Delete instead. </summary>
Task LeaveAsync();
Task LeaveAsync(RequestOptions options = null);
/// <summary> Gets a collection of all users banned on this guild. </summary>
Task<IReadOnlyCollection<IBan>> GetBansAsync();
Task<IReadOnlyCollection<IBan>> GetBansAsync(RequestOptions options = null);
/// <summary> Bans the provided user from this guild and optionally prunes their recent messages. </summary>
Task AddBanAsync(IUser user, int pruneDays = 0);
Task AddBanAsync(IUser user, int pruneDays = 0, RequestOptions options = null);
/// <summary> Bans the provided user id from this guild and optionally prunes their recent messages. </summary>
Task AddBanAsync(ulong userId, int pruneDays = 0);
Task AddBanAsync(ulong userId, int pruneDays = 0, RequestOptions options = null);
/// <summary> Unbans the provided user if it is currently banned. </summary>
Task RemoveBanAsync(IUser user);
Task RemoveBanAsync(IUser user, RequestOptions options = null);
/// <summary> Unbans the provided user id if it is currently banned. </summary>
Task RemoveBanAsync(ulong userId);
Task RemoveBanAsync(ulong userId, RequestOptions options = null);
/// <summary> Gets a collection of all channels in this guild. </summary>
Task<IReadOnlyCollection<IGuildChannel>> GetChannelsAsync(CacheMode mode = CacheMode.AllowDownload);
Task<IReadOnlyCollection<IGuildChannel>> GetChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Gets the channel in this guild with the provided id, or null if not found. </summary>
Task<IGuildChannel> GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload);
Task<IGuildChannel> GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Creates a new text channel. </summary>
Task<ITextChannel> CreateTextChannelAsync(string name);
Task<ITextChannel> CreateTextChannelAsync(string name, RequestOptions options = null);
/// <summary> Creates a new voice channel. </summary>
Task<IVoiceChannel> CreateVoiceChannelAsync(string name);
Task<IVoiceChannel> CreateVoiceChannelAsync(string name, RequestOptions options = null);
Task<IReadOnlyCollection<IGuildIntegration>> GetIntegrationsAsync();
Task<IGuildIntegration> CreateIntegrationAsync(ulong id, string type);
Task<IReadOnlyCollection<IGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null);
Task<IGuildIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null);
/// <summary> Gets a collection of all invites to this guild. </summary>
Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync();
Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null);
/// <summary> Gets the role in this guild with the provided id, or null if not found. </summary>
IRole GetRole(ulong id);
/// <summary> Creates a new role. </summary>
Task<IRole> CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false);
Task<IRole> CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false, RequestOptions options = null);
/// <summary> Gets a collection of all users in this guild. </summary>
Task<IReadOnlyCollection<IGuildUser>> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload); //TODO: shouldnt this be paged?
Task<IReadOnlyCollection<IGuildUser>> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); //TODO: shouldnt this be paged?
/// <summary> Gets the user in this guild with the provided id, or null if not found. </summary>
Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload);
Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Gets the current user for this guild. </summary>
Task<IGuildUser> GetCurrentUserAsync(CacheMode mode = CacheMode.AllowDownload);
Task<IGuildUser> GetCurrentUserAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Downloads all users for this guild if the current list is incomplete. </summary>
Task DownloadUsersAsync();
/// <summary> Removes all users from this guild if they have not logged on in a provided number of days or, if simulate is true, returns the number of users that would be removed. </summary>
Task<int> PruneUsersAsync(int days = 30, bool simulate = false);
Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null);
}
}

View File

@@ -5,6 +5,6 @@ namespace Discord
public interface IDeletable
{
/// <summary> Deletes this object and all its children. </summary>
Task DeleteAsync();
Task DeleteAsync(RequestOptions options = null);
}
}

View File

@@ -5,6 +5,6 @@ namespace Discord
public interface IUpdateable
{
/// <summary> Updates this object's properties with its current state. </summary>
Task UpdateAsync();
Task UpdateAsync(RequestOptions options = null);
}
}

View File

@@ -15,6 +15,6 @@ namespace Discord
ulong GuildId { get; }
/// <summary> Accepts this invite and joins the target guild. This will fail on bot accounts. </summary>
Task AcceptAsync();
Task AcceptAsync(RequestOptions options = null);
}
}

View File

@@ -7,11 +7,11 @@ namespace Discord
public interface IUserMessage : IMessage, IDeletable
{
/// <summary> Modifies this message. </summary>
Task ModifyAsync(Action<ModifyMessageParams> func);
Task ModifyAsync(Action<ModifyMessageParams> func, RequestOptions options = null);
/// <summary> Adds this message to its channel's pinned messages. </summary>
Task PinAsync();
Task PinAsync(RequestOptions options = null);
/// <summary> Removes this message from its channel's pinned messages. </summary>
Task UnpinAsync();
Task UnpinAsync(RequestOptions options = null);
/// <summary> Transforms this message's text into a human readable form, resolving mentions to that object's name. </summary>
string Resolve(int startIndex, int length,

View File

@@ -1,4 +1,8 @@
namespace Discord
using Discord.API.Rest;
using System;
using System.Threading.Tasks;
namespace Discord
{
public interface IRole : ISnowflakeEntity, IDeletable, IMentionable
{
@@ -19,6 +23,6 @@
int Position { get; }
///// <summary> Modifies this role. </summary>
//Task ModifyAsync(Action<ModifyGuildRoleParams> func);
Task ModifyAsync(Action<ModifyGuildRoleParams> func, RequestOptions options = null);
}
}

View File

@@ -3,6 +3,6 @@
public interface IGroupUser : IUser, IVoiceState
{
///// <summary> Kicks this user from this group. </summary>
//Task KickAsync();
//Task KickAsync(RequestOptions options = null);
}
}

View File

@@ -23,8 +23,8 @@ namespace Discord
ChannelPermissions GetPermissions(IGuildChannel channel);
/// <summary> Kicks this user from this guild. </summary>
Task KickAsync();
Task KickAsync(RequestOptions options = null);
/// <summary> Modifies this user's properties in this guild. </summary>
Task ModifyAsync(Action<ModifyGuildMemberParams> func);
Task ModifyAsync(Action<ModifyGuildMemberParams> func, RequestOptions options = null);
}
}

View File

@@ -13,7 +13,7 @@ namespace Discord
/// <summary> Returns true if this user has enabled MFA on their account. </summary>
bool IsMfaEnabled { get; }
Task ModifyAsync(Action<ModifyCurrentUserParams> func);
Task ModifyStatusAsync(Action<ModifyPresenceParams> func);
Task ModifyAsync(Action<ModifyCurrentUserParams> func, RequestOptions options = null);
Task ModifyStatusAsync(Action<ModifyPresenceParams> func, RequestOptions options = null);
}
}

View File

@@ -18,8 +18,8 @@ namespace Discord
string Username { get; }
/// <summary> Returns a private message channel to this user, creating one if it does not already exist. </summary>
Task<IDMChannel> GetDMChannelAsync(CacheMode mode = CacheMode.AllowDownload);
Task<IDMChannel> GetDMChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary> Returns a private message channel to this user, creating one if it does not already exist. </summary>
Task<IDMChannel> CreateDMChannelAsync();
Task<IDMChannel> CreateDMChannelAsync(RequestOptions options = null);
}
}