diff --git a/src/Discord.Net.Core/Entities/Channels/IChannel.cs b/src/Discord.Net.Core/Entities/Channels/IChannel.cs
index 6302e993c..97e58355c 100644
--- a/src/Discord.Net.Core/Entities/Channels/IChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IChannel.cs
@@ -6,9 +6,9 @@ namespace Discord
public interface IChannel : ISnowflakeEntity
{
/// Gets a collection of all users in this channel.
- IAsyncEnumerable> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload);
+ IAsyncEnumerable> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Gets a user in this channel with the provided id.
- Task GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload);
+ Task GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
}
}
diff --git a/src/Discord.Net.Core/Entities/Channels/IDMChannel.cs b/src/Discord.Net.Core/Entities/Channels/IDMChannel.cs
index a5a3a4168..1608d1543 100644
--- a/src/Discord.Net.Core/Entities/Channels/IDMChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IDMChannel.cs
@@ -8,6 +8,6 @@ namespace Discord
IUser Recipient { get; }
/// Closes this private channel, removing it from your channel list.
- Task CloseAsync();
+ Task CloseAsync(RequestOptions options = null);
}
}
\ No newline at end of file
diff --git a/src/Discord.Net.Core/Entities/Channels/IGroupChannel.cs b/src/Discord.Net.Core/Entities/Channels/IGroupChannel.cs
index 23f5b4784..d6cb2c182 100644
--- a/src/Discord.Net.Core/Entities/Channels/IGroupChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IGroupChannel.cs
@@ -5,6 +5,6 @@ namespace Discord
public interface IGroupChannel : IMessageChannel, IPrivateChannel, IAudioChannel
{
/// Leaves this group.
- Task LeaveAsync();
+ Task LeaveAsync(RequestOptions options = null);
}
}
\ No newline at end of file
diff --git a/src/Discord.Net.Core/Entities/Channels/IGuildChannel.cs b/src/Discord.Net.Core/Entities/Channels/IGuildChannel.cs
index 085771fbf..bb9f39c71 100644
--- a/src/Discord.Net.Core/Entities/Channels/IGuildChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IGuildChannel.cs
@@ -21,29 +21,29 @@ namespace Discord
/// The time (in seconds) until the invite expires. Set to null to never expire.
/// The max amount of times this invite may be used. Set to null to have unlimited uses.
/// If true, a user accepting this invite will be kicked from the guild after closing their client.
- Task CreateInviteAsync(int? maxAge = 1800, int? maxUses = default(int?), bool isTemporary = false);
+ Task CreateInviteAsync(int? maxAge = 1800, int? maxUses = default(int?), bool isTemporary = false, RequestOptions options = null);
/// Returns a collection of all invites to this channel.
- Task> GetInvitesAsync();
+ Task> GetInvitesAsync(RequestOptions options = null);
/// Modifies this guild channel.
- Task ModifyAsync(Action func);
+ Task ModifyAsync(Action func, RequestOptions options = null);
/// Gets the permission overwrite for a specific role, or null if one does not exist.
OverwritePermissions? GetPermissionOverwrite(IRole role);
/// Gets the permission overwrite for a specific user, or null if one does not exist.
OverwritePermissions? GetPermissionOverwrite(IUser user);
/// Removes the permission overwrite for the given role, if one exists.
- Task RemovePermissionOverwriteAsync(IRole role);
+ Task RemovePermissionOverwriteAsync(IRole role, RequestOptions options = null);
/// Removes the permission overwrite for the given user, if one exists.
- Task RemovePermissionOverwriteAsync(IUser user);
+ Task RemovePermissionOverwriteAsync(IUser user, RequestOptions options = null);
/// Adds or updates the permission overwrite for the given role.
- Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions);
+ Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null);
/// Adds or updates the permission overwrite for the given user.
- Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions);
+ Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null);
/// Gets a collection of all users in this channel.
- new IAsyncEnumerable> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload);
+ new IAsyncEnumerable> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Gets a user in this channel with the provided id.
- new Task GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload);
+ new Task GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
}
}
\ No newline at end of file
diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
index 2fa09cd08..77ed811eb 100644
--- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
@@ -8,26 +8,29 @@ namespace Discord
public interface IMessageChannel : IChannel
{
/// Sends a message to this message channel.
- Task SendMessageAsync(string text, bool isTTS = false);
+ Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null);
/// Sends a file to this text channel, with an optional caption.
- Task SendFileAsync(string filePath, string text = null, bool isTTS = false);
+ Task SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null);
/// Sends a file to this text channel, with an optional caption.
- Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false);
+ Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, RequestOptions options = null);
/// Gets a message from this message channel with the given id, or null if not found.
- Task GetMessageAsync(ulong id, CacheMode mode = CacheMode.AllowDownload);
+ Task GetMessageAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Gets the last N messages from this message channel.
- IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, CacheMode mode = CacheMode.AllowDownload);
+ IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch,
+ CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Gets a collection of messages in this channel.
- IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, CacheMode mode = CacheMode.AllowDownload);
+ IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch,
+ CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Gets a collection of messages in this channel.
- IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, CacheMode mode = CacheMode.AllowDownload);
+ IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch,
+ CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Gets a collection of pinned messages in this channel.
- Task> GetPinnedMessagesAsync();
+ Task> GetPinnedMessagesAsync(RequestOptions options = null);
/// Bulk deletes multiple messages.
- Task DeleteMessagesAsync(IEnumerable messages);
+ Task DeleteMessagesAsync(IEnumerable messages, RequestOptions options = null);
/// Broadcasts the "user is typing" message to all users in this channel, lasting 10 seconds.
- IDisposable EnterTypingState();
+ IDisposable EnterTypingState(RequestOptions options = null);
}
}
diff --git a/src/Discord.Net.Core/Entities/Channels/ITextChannel.cs b/src/Discord.Net.Core/Entities/Channels/ITextChannel.cs
index 3b4248b6e..7ecaf6d7b 100644
--- a/src/Discord.Net.Core/Entities/Channels/ITextChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/ITextChannel.cs
@@ -10,6 +10,6 @@ namespace Discord
string Topic { get; }
/// Modifies this text channel.
- Task ModifyAsync(Action func);
+ Task ModifyAsync(Action func, RequestOptions options = null);
}
}
\ No newline at end of file
diff --git a/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs b/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs
index 75f6a0190..d1be73072 100644
--- a/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs
@@ -13,7 +13,7 @@ namespace Discord
int UserLimit { get; }
/// Modifies this voice channel.
- Task ModifyAsync(Action func);
+ Task ModifyAsync(Action func, RequestOptions options = null);
/// Connects to this voice channel.
Task ConnectAsync();
}
diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
index f1b1da6a1..2ff7afa3f 100644
--- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
+++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
@@ -53,56 +53,56 @@ namespace Discord
IReadOnlyCollection Roles { get; }
/// Modifies this guild.
- Task ModifyAsync(Action func);
+ Task ModifyAsync(Action func, RequestOptions options = null);
/// Modifies this guild's embed.
- Task ModifyEmbedAsync(Action func);
+ Task ModifyEmbedAsync(Action func, RequestOptions options = null);
/// Bulk modifies the channels of this guild.
- Task ModifyChannelsAsync(IEnumerable args);
+ Task ModifyChannelsAsync(IEnumerable args, RequestOptions options = null);
/// Bulk modifies the roles of this guild.
- Task ModifyRolesAsync(IEnumerable args);
+ Task ModifyRolesAsync(IEnumerable args, RequestOptions options = null);
/// Leaves this guild. If you are the owner, use Delete instead.
- Task LeaveAsync();
+ Task LeaveAsync(RequestOptions options = null);
/// Gets a collection of all users banned on this guild.
- Task> GetBansAsync();
+ Task> GetBansAsync(RequestOptions options = null);
/// Bans the provided user from this guild and optionally prunes their recent messages.
- Task AddBanAsync(IUser user, int pruneDays = 0);
+ Task AddBanAsync(IUser user, int pruneDays = 0, RequestOptions options = null);
/// Bans the provided user id from this guild and optionally prunes their recent messages.
- Task AddBanAsync(ulong userId, int pruneDays = 0);
+ Task AddBanAsync(ulong userId, int pruneDays = 0, RequestOptions options = null);
/// Unbans the provided user if it is currently banned.
- Task RemoveBanAsync(IUser user);
+ Task RemoveBanAsync(IUser user, RequestOptions options = null);
/// Unbans the provided user id if it is currently banned.
- Task RemoveBanAsync(ulong userId);
+ Task RemoveBanAsync(ulong userId, RequestOptions options = null);
/// Gets a collection of all channels in this guild.
- Task> GetChannelsAsync(CacheMode mode = CacheMode.AllowDownload);
+ Task> GetChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Gets the channel in this guild with the provided id, or null if not found.
- Task GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload);
+ Task GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Creates a new text channel.
- Task CreateTextChannelAsync(string name);
+ Task CreateTextChannelAsync(string name, RequestOptions options = null);
/// Creates a new voice channel.
- Task CreateVoiceChannelAsync(string name);
+ Task CreateVoiceChannelAsync(string name, RequestOptions options = null);
- Task> GetIntegrationsAsync();
- Task CreateIntegrationAsync(ulong id, string type);
+ Task> GetIntegrationsAsync(RequestOptions options = null);
+ Task CreateIntegrationAsync(ulong id, string type, RequestOptions options = null);
/// Gets a collection of all invites to this guild.
- Task> GetInvitesAsync();
+ Task> GetInvitesAsync(RequestOptions options = null);
/// Gets the role in this guild with the provided id, or null if not found.
IRole GetRole(ulong id);
/// Creates a new role.
- Task CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false);
+ Task CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false, RequestOptions options = null);
/// Gets a collection of all users in this guild.
- Task> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload); //TODO: shouldnt this be paged?
+ Task> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); //TODO: shouldnt this be paged?
/// Gets the user in this guild with the provided id, or null if not found.
- Task GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload);
+ Task GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Gets the current user for this guild.
- Task GetCurrentUserAsync(CacheMode mode = CacheMode.AllowDownload);
+ Task GetCurrentUserAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Downloads all users for this guild if the current list is incomplete.
Task DownloadUsersAsync();
/// 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.
- Task PruneUsersAsync(int days = 30, bool simulate = false);
+ Task PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null);
}
}
\ No newline at end of file
diff --git a/src/Discord.Net.Core/Entities/IDeletable.cs b/src/Discord.Net.Core/Entities/IDeletable.cs
index f35f8ad88..ba22a537a 100644
--- a/src/Discord.Net.Core/Entities/IDeletable.cs
+++ b/src/Discord.Net.Core/Entities/IDeletable.cs
@@ -5,6 +5,6 @@ namespace Discord
public interface IDeletable
{
/// Deletes this object and all its children.
- Task DeleteAsync();
+ Task DeleteAsync(RequestOptions options = null);
}
}
diff --git a/src/Discord.Net.Core/Entities/IUpdateable.cs b/src/Discord.Net.Core/Entities/IUpdateable.cs
index 50b23bb95..b0f51aee7 100644
--- a/src/Discord.Net.Core/Entities/IUpdateable.cs
+++ b/src/Discord.Net.Core/Entities/IUpdateable.cs
@@ -5,6 +5,6 @@ namespace Discord
public interface IUpdateable
{
/// Updates this object's properties with its current state.
- Task UpdateAsync();
+ Task UpdateAsync(RequestOptions options = null);
}
}
diff --git a/src/Discord.Net.Core/Entities/Invites/IInvite.cs b/src/Discord.Net.Core/Entities/Invites/IInvite.cs
index 5e5ca40ae..081b57d76 100644
--- a/src/Discord.Net.Core/Entities/Invites/IInvite.cs
+++ b/src/Discord.Net.Core/Entities/Invites/IInvite.cs
@@ -15,6 +15,6 @@ namespace Discord
ulong GuildId { get; }
/// Accepts this invite and joins the target guild. This will fail on bot accounts.
- Task AcceptAsync();
+ Task AcceptAsync(RequestOptions options = null);
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs b/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
index fd170dacb..3faa31419 100644
--- a/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
+++ b/src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
@@ -7,11 +7,11 @@ namespace Discord
public interface IUserMessage : IMessage, IDeletable
{
/// Modifies this message.
- Task ModifyAsync(Action func);
+ Task ModifyAsync(Action func, RequestOptions options = null);
/// Adds this message to its channel's pinned messages.
- Task PinAsync();
+ Task PinAsync(RequestOptions options = null);
/// Removes this message from its channel's pinned messages.
- Task UnpinAsync();
+ Task UnpinAsync(RequestOptions options = null);
/// Transforms this message's text into a human readable form, resolving mentions to that object's name.
string Resolve(int startIndex, int length,
diff --git a/src/Discord.Net.Core/Entities/Roles/IRole.cs b/src/Discord.Net.Core/Entities/Roles/IRole.cs
index bcea9b17e..d7de45b88 100644
--- a/src/Discord.Net.Core/Entities/Roles/IRole.cs
+++ b/src/Discord.Net.Core/Entities/Roles/IRole.cs
@@ -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; }
///// Modifies this role.
- //Task ModifyAsync(Action func);
+ Task ModifyAsync(Action func, RequestOptions options = null);
}
}
\ No newline at end of file
diff --git a/src/Discord.Net.Core/Entities/Users/IGroupUser.cs b/src/Discord.Net.Core/Entities/Users/IGroupUser.cs
index 3d18b7cd2..dd046a5a8 100644
--- a/src/Discord.Net.Core/Entities/Users/IGroupUser.cs
+++ b/src/Discord.Net.Core/Entities/Users/IGroupUser.cs
@@ -3,6 +3,6 @@
public interface IGroupUser : IUser, IVoiceState
{
///// Kicks this user from this group.
- //Task KickAsync();
+ //Task KickAsync(RequestOptions options = null);
}
}
diff --git a/src/Discord.Net.Core/Entities/Users/IGuildUser.cs b/src/Discord.Net.Core/Entities/Users/IGuildUser.cs
index 72cbabb30..7763a14ae 100644
--- a/src/Discord.Net.Core/Entities/Users/IGuildUser.cs
+++ b/src/Discord.Net.Core/Entities/Users/IGuildUser.cs
@@ -23,8 +23,8 @@ namespace Discord
ChannelPermissions GetPermissions(IGuildChannel channel);
/// Kicks this user from this guild.
- Task KickAsync();
+ Task KickAsync(RequestOptions options = null);
/// Modifies this user's properties in this guild.
- Task ModifyAsync(Action func);
+ Task ModifyAsync(Action func, RequestOptions options = null);
}
}
diff --git a/src/Discord.Net.Core/Entities/Users/ISelfUser.cs b/src/Discord.Net.Core/Entities/Users/ISelfUser.cs
index dea95b566..a6e8f80e8 100644
--- a/src/Discord.Net.Core/Entities/Users/ISelfUser.cs
+++ b/src/Discord.Net.Core/Entities/Users/ISelfUser.cs
@@ -13,7 +13,7 @@ namespace Discord
/// Returns true if this user has enabled MFA on their account.
bool IsMfaEnabled { get; }
- Task ModifyAsync(Action func);
- Task ModifyStatusAsync(Action func);
+ Task ModifyAsync(Action func, RequestOptions options = null);
+ Task ModifyStatusAsync(Action func, RequestOptions options = null);
}
}
\ No newline at end of file
diff --git a/src/Discord.Net.Core/Entities/Users/IUser.cs b/src/Discord.Net.Core/Entities/Users/IUser.cs
index 43f441e7e..c02f8aeca 100644
--- a/src/Discord.Net.Core/Entities/Users/IUser.cs
+++ b/src/Discord.Net.Core/Entities/Users/IUser.cs
@@ -18,8 +18,8 @@ namespace Discord
string Username { get; }
/// Returns a private message channel to this user, creating one if it does not already exist.
- Task GetDMChannelAsync(CacheMode mode = CacheMode.AllowDownload);
+ Task GetDMChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// Returns a private message channel to this user, creating one if it does not already exist.
- Task CreateDMChannelAsync();
+ Task CreateDMChannelAsync(RequestOptions options = null);
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
index 37c7ed6dd..319520386 100644
--- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
@@ -12,67 +12,64 @@ namespace Discord.Rest
internal static class ChannelHelper
{
//General
- public static async Task GetAsync(IGuildChannel channel, BaseDiscordClient client)
- {
- return await client.ApiClient.GetChannelAsync(channel.GuildId, channel.Id).ConfigureAwait(false);
- }
- public static async Task GetAsync(IPrivateChannel channel, BaseDiscordClient client)
- {
- return await client.ApiClient.GetChannelAsync(channel.Id).ConfigureAwait(false);
- }
- public static async Task DeleteAsync(IChannel channel, BaseDiscordClient client)
+ public static async Task DeleteAsync(IChannel channel, BaseDiscordClient client,
+ RequestOptions options)
{
- await client.ApiClient.DeleteChannelAsync(channel.Id).ConfigureAwait(false);
+ await client.ApiClient.DeleteChannelAsync(channel.Id, options).ConfigureAwait(false);
}
public static async Task ModifyAsync(IGuildChannel channel, BaseDiscordClient client,
- Action func)
+ Action func,
+ RequestOptions options)
{
var args = new ModifyGuildChannelParams();
func(args);
- await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args);
+ await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options);
}
public static async Task ModifyAsync(ITextChannel channel, BaseDiscordClient client,
- Action func)
+ Action func,
+ RequestOptions options)
{
var args = new ModifyTextChannelParams();
func(args);
- await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args);
+ await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options);
}
public static async Task ModifyAsync(IVoiceChannel channel, BaseDiscordClient client,
- Action func)
+ Action func,
+ RequestOptions options)
{
var args = new ModifyVoiceChannelParams();
func(args);
- await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args);
+ await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options);
}
//Invites
- public static async Task> GetInvitesAsync(IChannel channel, BaseDiscordClient client)
+ public static async Task> GetInvitesAsync(IChannel channel, BaseDiscordClient client,
+ RequestOptions options)
{
- var models = await client.ApiClient.GetChannelInvitesAsync(channel.Id);
+ var models = await client.ApiClient.GetChannelInvitesAsync(channel.Id, options);
return models.Select(x => RestInviteMetadata.Create(client, x)).ToImmutableArray();
}
public static async Task CreateInviteAsync(IChannel channel, BaseDiscordClient client,
- int? maxAge, int? maxUses, bool isTemporary)
+ int? maxAge, int? maxUses, bool isTemporary, RequestOptions options)
{
var args = new CreateChannelInviteParams { IsTemporary = isTemporary };
if (maxAge.HasValue)
args.MaxAge = maxAge.Value;
if (maxUses.HasValue)
args.MaxUses = maxUses.Value;
- var model = await client.ApiClient.CreateChannelInviteAsync(channel.Id, args);
+ var model = await client.ApiClient.CreateChannelInviteAsync(channel.Id, args, options);
return RestInviteMetadata.Create(client, model);
}
//Messages
public static async Task GetMessageAsync(IChannel channel, BaseDiscordClient client,
- ulong id)
+ ulong id, RequestOptions options)
{
- var model = await client.ApiClient.GetChannelMessageAsync(channel.Id, id).ConfigureAwait(false);
+ var model = await client.ApiClient.GetChannelMessageAsync(channel.Id, id, options).ConfigureAwait(false);
return RestMessage.Create(client, model);
}
public static IAsyncEnumerable> GetMessagesAsync(IChannel channel, BaseDiscordClient client,
- ulong? fromMessageId = null, Direction dir = Direction.Before, int limit = DiscordConfig.MaxMessagesPerBatch)
+ ulong? fromMessageId, Direction dir, int limit, RequestOptions options)
{
//TODO: Test this with Around direction
return new PagedAsyncEnumerable(
@@ -86,7 +83,7 @@ namespace Discord.Rest
};
if (info.Position != null)
args.RelativeMessageId = info.Position.Value;
- var models = await client.ApiClient.GetChannelMessagesAsync(channel.Id, args);
+ var models = await client.ApiClient.GetChannelMessagesAsync(channel.Id, args, options);
return models.Select(x => RestMessage.Create(client, x)).ToImmutableArray(); ;
},
nextPage: (info, lastPage) =>
@@ -102,71 +99,72 @@ namespace Discord.Rest
count: limit
);
}
- public static async Task> GetPinnedMessagesAsync(IChannel channel, BaseDiscordClient client)
+ public static async Task> GetPinnedMessagesAsync(IChannel channel, BaseDiscordClient client,
+ RequestOptions options)
{
- var models = await client.ApiClient.GetPinsAsync(channel.Id).ConfigureAwait(false);
+ var models = await client.ApiClient.GetPinsAsync(channel.Id, options).ConfigureAwait(false);
return models.Select(x => RestMessage.Create(client, x)).ToImmutableArray();
}
public static async Task SendMessageAsync(IChannel channel, BaseDiscordClient client,
- string text, bool isTTS)
+ string text, bool isTTS, RequestOptions options)
{
var args = new CreateMessageParams(text) { IsTTS = isTTS };
- var model = await client.ApiClient.CreateMessageAsync(channel.Id, args).ConfigureAwait(false);
+ var model = await client.ApiClient.CreateMessageAsync(channel.Id, args, options).ConfigureAwait(false);
return RestUserMessage.Create(client, model);
}
public static Task SendFileAsync(IChannel channel, BaseDiscordClient client,
- string filePath, string text, bool isTTS)
+ string filePath, string text, bool isTTS, RequestOptions options)
{
string filename = Path.GetFileName(filePath);
using (var file = File.OpenRead(filePath))
- return SendFileAsync(channel, client, file, filename, text, isTTS);
+ return SendFileAsync(channel, client, file, filename, text, isTTS, options);
}
public static async Task SendFileAsync(IChannel channel, BaseDiscordClient client,
- Stream stream, string filename, string text, bool isTTS)
+ Stream stream, string filename, string text, bool isTTS, RequestOptions options)
{
var args = new UploadFileParams(stream) { Filename = filename, Content = text, IsTTS = isTTS };
- var model = await client.ApiClient.UploadFileAsync(channel.Id, args).ConfigureAwait(false);
+ var model = await client.ApiClient.UploadFileAsync(channel.Id, args, options).ConfigureAwait(false);
return RestUserMessage.Create(client, model);
}
public static async Task DeleteMessagesAsync(IChannel channel, BaseDiscordClient client,
- IEnumerable messages)
+ IEnumerable messages, RequestOptions options)
{
var args = new DeleteMessagesParams(messages.Select(x => x.Id).ToArray());
- await client.ApiClient.DeleteMessagesAsync(channel.Id, args).ConfigureAwait(false);
+ await client.ApiClient.DeleteMessagesAsync(channel.Id, args, options).ConfigureAwait(false);
}
//Permission Overwrites
public static async Task AddPermissionOverwriteAsync(IGuildChannel channel, BaseDiscordClient client,
- IUser user, OverwritePermissions perms)
+ IUser user, OverwritePermissions perms, RequestOptions options)
{
var args = new ModifyChannelPermissionsParams("member", perms.AllowValue, perms.DenyValue);
- await client.ApiClient.ModifyChannelPermissionsAsync(channel.Id, user.Id, args).ConfigureAwait(false);
+ await client.ApiClient.ModifyChannelPermissionsAsync(channel.Id, user.Id, args, options).ConfigureAwait(false);
}
public static async Task AddPermissionOverwriteAsync(IGuildChannel channel, BaseDiscordClient client,
- IRole role, OverwritePermissions perms)
+ IRole role, OverwritePermissions perms, RequestOptions options)
{
var args = new ModifyChannelPermissionsParams("role", perms.AllowValue, perms.DenyValue);
- await client.ApiClient.ModifyChannelPermissionsAsync(channel.Id, role.Id, args).ConfigureAwait(false);
+ await client.ApiClient.ModifyChannelPermissionsAsync(channel.Id, role.Id, args, options).ConfigureAwait(false);
}
public static async Task RemovePermissionOverwriteAsync(IGuildChannel channel, BaseDiscordClient client,
- IUser user)
+ IUser user, RequestOptions options)
{
- await client.ApiClient.DeleteChannelPermissionAsync(channel.Id, user.Id).ConfigureAwait(false);
+ await client.ApiClient.DeleteChannelPermissionAsync(channel.Id, user.Id, options).ConfigureAwait(false);
}
public static async Task RemovePermissionOverwriteAsync(IGuildChannel channel, BaseDiscordClient client,
- IRole role)
+ IRole role, RequestOptions options)
{
- await client.ApiClient.DeleteChannelPermissionAsync(channel.Id, role.Id).ConfigureAwait(false);
+ await client.ApiClient.DeleteChannelPermissionAsync(channel.Id, role.Id, options).ConfigureAwait(false);
}
//Users
public static async Task GetUserAsync(IGuildChannel channel, IGuild guild, BaseDiscordClient client,
- ulong id)
+ ulong id, RequestOptions options)
{
- var model = await client.ApiClient.GetGuildMemberAsync(channel.GuildId, id);
+ var model = await client.ApiClient.GetGuildMemberAsync(channel.GuildId, id, options);
if (model == null)
return null;
var user = RestGuildUser.Create(client, guild, model);
@@ -176,7 +174,7 @@ namespace Discord.Rest
return user;
}
public static IAsyncEnumerable> GetUsersAsync(IGuildChannel channel, IGuild guild, BaseDiscordClient client,
- ulong? froUserId = null, int? limit = DiscordConfig.MaxUsersPerBatch)
+ ulong? fromUserId, int? limit, RequestOptions options)
{
return new PagedAsyncEnumerable(
DiscordConfig.MaxUsersPerBatch,
@@ -188,7 +186,7 @@ namespace Discord.Rest
};
if (info.Position != null)
args.AfterUserId = info.Position.Value;
- var models = await guild.Discord.ApiClient.GetGuildMembersAsync(guild.Id, args);
+ var models = await guild.Discord.ApiClient.GetGuildMembersAsync(guild.Id, args, options);
return models
.Select(x => RestGuildUser.Create(client, guild, x))
.Where(x => x.GetPermissions(channel).ReadMessages)
@@ -200,13 +198,14 @@ namespace Discord.Rest
if (lastPage.Count != DiscordConfig.MaxMessagesPerBatch)
info.Remaining = 0;
},
- start: froUserId,
+ start: fromUserId,
count: limit
);
}
//Typing
- public static IDisposable EnterTypingState(IChannel channel, BaseDiscordClient client)
- => new TypingNotifier(client, channel);
+ public static IDisposable EnterTypingState(IChannel channel, BaseDiscordClient client,
+ RequestOptions options)
+ => new TypingNotifier(client, channel, options);
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs
index 3d1233cef..6d2b729dd 100644
--- a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs
@@ -7,21 +7,21 @@ namespace Discord.Rest
public interface IRestMessageChannel : IMessageChannel
{
/// Sends a message to this message channel.
- new Task SendMessageAsync(string text, bool isTTS = false);
+ new Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null);
/// Sends a file to this text channel, with an optional caption.
- new Task SendFileAsync(string filePath, string text = null, bool isTTS = false);
+ new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null);
/// Sends a file to this text channel, with an optional caption.
- new Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false);
+ new Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, RequestOptions options = null);
/// Gets a message from this message channel with the given id, or null if not found.
- Task GetMessageAsync(ulong id);
+ Task GetMessageAsync(ulong id, RequestOptions options = null);
/// Gets the last N messages from this message channel.
- IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch);
+ IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null);
/// Gets a collection of messages in this channel.
- IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch);
+ IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null);
/// Gets a collection of messages in this channel.
- IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch);
+ IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null);
/// Gets a collection of pinned messages in this channel.
- new Task> GetPinnedMessagesAsync();
+ new Task> GetPinnedMessagesAsync(RequestOptions options = null);
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs
index 952a9e0fe..04305c6b8 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs
@@ -41,12 +41,12 @@ namespace Discord.Rest
}
internal abstract void Update(Model model);
- public abstract Task UpdateAsync();
+ public abstract Task UpdateAsync(RequestOptions options = null);
//IChannel
- Task IChannel.GetUserAsync(ulong id, CacheMode mode)
+ Task IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult(null); //Overriden
- IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode)
+ IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> AsyncEnumerable.Empty>(); //Overriden
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
index 43f318abe..3adbd3fa4 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
@@ -34,10 +34,13 @@ namespace Discord.Rest
Recipient.Update(model.Recipients.Value[0]);
}
- public override async Task UpdateAsync()
- => Update(await ChannelHelper.GetAsync(this, Discord));
- public Task CloseAsync()
- => ChannelHelper.DeleteAsync(this, Discord);
+ public override async Task UpdateAsync(RequestOptions options = null)
+ {
+ var model = await Discord.ApiClient.GetChannelAsync(Id, options);
+ Update(model);
+ }
+ public Task CloseAsync(RequestOptions options = null)
+ => ChannelHelper.DeleteAsync(this, Discord, options);
public RestUser GetUser(ulong id)
{
@@ -49,29 +52,29 @@ namespace Discord.Rest
return null;
}
- public Task GetMessageAsync(ulong id)
- => ChannelHelper.GetMessageAsync(this, Discord, id);
- public IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch)
- => ChannelHelper.GetMessagesAsync(this, Discord, limit: limit);
- public IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
- => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit);
- public IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
- => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit);
- public Task> GetPinnedMessagesAsync()
- => ChannelHelper.GetPinnedMessagesAsync(this, Discord);
-
- public Task SendMessageAsync(string text, bool isTTS)
- => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS);
- public Task SendFileAsync(string filePath, string text, bool isTTS)
- => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS);
- public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS)
- => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS);
-
- public Task DeleteMessagesAsync(IEnumerable messages)
- => ChannelHelper.DeleteMessagesAsync(this, Discord, messages);
-
- public IDisposable EnterTypingState()
- => ChannelHelper.EnterTypingState(this, Discord);
+ public Task GetMessageAsync(ulong id, RequestOptions options = null)
+ => ChannelHelper.GetMessageAsync(this, Discord, id, options);
+ public IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
+ => ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options);
+ public IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
+ => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options);
+ public IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
+ => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options);
+ public Task> GetPinnedMessagesAsync(RequestOptions options = null)
+ => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
+
+ public Task SendMessageAsync(string text, bool isTTS, RequestOptions options = null)
+ => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, options);
+ public Task SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options = null)
+ => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
+ public Task 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 messages, RequestOptions options = null)
+ => ChannelHelper.DeleteMessagesAsync(this, Discord, messages, options);
+
+ public IDisposable EnterTypingState(RequestOptions options = null)
+ => ChannelHelper.EnterTypingState(this, Discord, options);
public override string ToString() => $"@{Recipient}";
private string DebuggerDisplay => $"@{Recipient} ({Id}, DM)";
@@ -86,49 +89,50 @@ namespace Discord.Rest
IReadOnlyCollection IPrivateChannel.Recipients => ImmutableArray.Create(Recipient);
//IMessageChannel
- async Task IMessageChannel.GetMessageAsync(ulong id, CacheMode mode)
+ async Task 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> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode)
+ IAsyncEnumerable> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
- return GetMessagesAsync(limit);
+ return GetMessagesAsync(limit, options);
else
return AsyncEnumerable.Empty>();
}
- IAsyncEnumerable> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode)
+ IAsyncEnumerable> 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>();
}
- IAsyncEnumerable> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode)
+ IAsyncEnumerable> 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>();
}
- async Task> IMessageChannel.GetPinnedMessagesAsync()
- => await GetPinnedMessagesAsync().ConfigureAwait(false);
- async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS)
- => await SendFileAsync(filePath, text, isTTS);
- async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS)
- => await SendFileAsync(stream, filename, text, isTTS);
- async Task IMessageChannel.SendMessageAsync(string text, bool isTTS)
- => await SendMessageAsync(text, isTTS);
- IDisposable IMessageChannel.EnterTypingState()
- => EnterTypingState();
+ async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
+ => await GetPinnedMessagesAsync(options);
+
+ async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
+ => await SendFileAsync(filePath, text, isTTS, options);
+ async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
+ => await SendFileAsync(stream, filename, text, isTTS, options);
+ async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
+ => await SendMessageAsync(text, isTTS, options);
+ IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
+ => EnterTypingState(options);
//IChannel
- Task IChannel.GetUserAsync(ulong id, CacheMode mode)
+ Task IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult(GetUser(id));
- IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode)
+ IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> ImmutableArray.Create>(Users).ToAsyncEnumerable();
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
index d06077a4a..4a1ea7b87 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
@@ -49,12 +49,15 @@ namespace Discord.Rest
_users = users.ToImmutable();
}
- public override async Task UpdateAsync()
- => Update(await ChannelHelper.GetAsync(this, Discord));
- public Task LeaveAsync()
- => ChannelHelper.DeleteAsync(this, Discord);
+ public override async Task UpdateAsync(RequestOptions options = null)
+ {
+ var model = await Discord.ApiClient.GetChannelAsync(Id, options);
+ Update(model);
+ }
+ public Task LeaveAsync(RequestOptions options = null)
+ => ChannelHelper.DeleteAsync(this, Discord, options);
- public IUser GetUser(ulong id)
+ public RestUser GetUser(ulong id)
{
RestGroupUser user;
if (_users.TryGetValue(id, out user))
@@ -62,29 +65,29 @@ namespace Discord.Rest
return null;
}
- public Task GetMessageAsync(ulong id)
- => ChannelHelper.GetMessageAsync(this, Discord, id);
- public IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch)
- => ChannelHelper.GetMessagesAsync(this, Discord, limit: limit);
- public IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
- => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit);
- public IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
- => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit);
- public Task> GetPinnedMessagesAsync()
- => ChannelHelper.GetPinnedMessagesAsync(this, Discord);
-
- public Task SendMessageAsync(string text, bool isTTS)
- => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS);
- public Task SendFileAsync(string filePath, string text, bool isTTS)
- => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS);
- public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS)
- => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS);
-
- public Task DeleteMessagesAsync(IEnumerable messages)
- => ChannelHelper.DeleteMessagesAsync(this, Discord, messages);
-
- public IDisposable EnterTypingState()
- => ChannelHelper.EnterTypingState(this, Discord);
+ public Task GetMessageAsync(ulong id, RequestOptions options = null)
+ => ChannelHelper.GetMessageAsync(this, Discord, id, options);
+ public IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
+ => ChannelHelper.GetMessagesAsync(this, Discord, null, Direction.Before, limit, options);
+ public IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
+ => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit, options);
+ public IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
+ => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options);
+ public Task> GetPinnedMessagesAsync(RequestOptions options = null)
+ => ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
+
+ public Task SendMessageAsync(string text, bool isTTS, RequestOptions options = null)
+ => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, options);
+ public Task SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options = null)
+ => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
+ public Task 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 messages, RequestOptions options = null)
+ => ChannelHelper.DeleteMessagesAsync(this, Discord, messages, options);
+
+ public IDisposable EnterTypingState(RequestOptions options = null)
+ => ChannelHelper.EnterTypingState(this, Discord, options);
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id}, Group)";
@@ -96,50 +99,50 @@ namespace Discord.Rest
IReadOnlyCollection IPrivateChannel.Recipients => Recipients;
//IMessageChannel
- async Task IMessageChannel.GetMessageAsync(ulong id, CacheMode mode)
+ async Task 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> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode)
+ IAsyncEnumerable> IMessageChannel.GetMessagesAsync(int limit, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
- return GetMessagesAsync(limit);
+ return GetMessagesAsync(limit, options);
else
return AsyncEnumerable.Empty>();
}
- IAsyncEnumerable> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode)
+ IAsyncEnumerable> 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>();
}
- IAsyncEnumerable> IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode)
+ IAsyncEnumerable> 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>();
}
- async Task> IMessageChannel.GetPinnedMessagesAsync()
- => await GetPinnedMessagesAsync();
-
- async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS)
- => await SendFileAsync(filePath, text, isTTS);
- async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS)
- => await SendFileAsync(stream, filename, text, isTTS);
- async Task IMessageChannel.SendMessageAsync(string text, bool isTTS)
- => await SendMessageAsync(text, isTTS);
- IDisposable IMessageChannel.EnterTypingState()
- => EnterTypingState();
+ async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
+ => await GetPinnedMessagesAsync(options);
+
+ async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
+ => await SendFileAsync(filePath, text, isTTS, options);
+ async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
+ => await SendFileAsync(stream, filename, text, isTTS, options);
+ async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options)
+ => await SendMessageAsync(text, isTTS, options);
+ IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
+ => EnterTypingState(options);
//IChannel
- Task IChannel.GetUserAsync(ulong id, CacheMode mode)
- => Task.FromResult(GetUser(id));
- IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode)
+ Task IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
+ => Task.FromResult(GetUser(id));
+ IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> ImmutableArray.Create>(Users).ToAsyncEnumerable();
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs
index 72dd4a48b..08ef88d46 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs
@@ -49,12 +49,15 @@ namespace Discord.Rest
_overwrites = newOverwrites.ToImmutable();
}
- public override async Task UpdateAsync()
- => Update(await ChannelHelper.GetAsync(this, Discord));
- public Task ModifyAsync(Action func)
- => ChannelHelper.ModifyAsync(this, Discord, func);
- public Task DeleteAsync()
- => ChannelHelper.DeleteAsync(this, Discord);
+ public override async Task UpdateAsync(RequestOptions options = null)
+ {
+ var model = await Discord.ApiClient.GetChannelAsync(GuildId, Id, options);
+ Update(model);
+ }
+ public Task ModifyAsync(Action func, RequestOptions options = null)
+ => ChannelHelper.ModifyAsync(this, Discord, func, options);
+ public Task DeleteAsync(RequestOptions options = null)
+ => ChannelHelper.DeleteAsync(this, Discord, options);
public OverwritePermissions? GetPermissionOverwrite(IUser user)
{
@@ -74,19 +77,19 @@ namespace Discord.Rest
}
return null;
}
- public async Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions perms)
+ public async Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions perms, RequestOptions options = null)
{
- await ChannelHelper.AddPermissionOverwriteAsync(this, Discord, user, perms).ConfigureAwait(false);
+ await ChannelHelper.AddPermissionOverwriteAsync(this, Discord, user, perms, options).ConfigureAwait(false);
_overwrites = _overwrites.Add(new Overwrite(new API.Overwrite { Allow = perms.AllowValue, Deny = perms.DenyValue, TargetId = user.Id, TargetType = PermissionTarget.User }));
}
- public async Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions perms)
+ public async Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions perms, RequestOptions options = null)
{
- await ChannelHelper.AddPermissionOverwriteAsync(this, Discord, role, perms).ConfigureAwait(false);
+ await ChannelHelper.AddPermissionOverwriteAsync(this, Discord, role, perms, options).ConfigureAwait(false);
_overwrites.Add(new Overwrite(new API.Overwrite { Allow = perms.AllowValue, Deny = perms.DenyValue, TargetId = role.Id, TargetType = PermissionTarget.Role }));
}
- public async Task RemovePermissionOverwriteAsync(IUser user)
+ public async Task RemovePermissionOverwriteAsync(IUser user, RequestOptions options = null)
{
- await ChannelHelper.RemovePermissionOverwriteAsync(this, Discord, user).ConfigureAwait(false);
+ await ChannelHelper.RemovePermissionOverwriteAsync(this, Discord, user, options).ConfigureAwait(false);
for (int i = 0; i < _overwrites.Length; i++)
{
@@ -97,9 +100,9 @@ namespace Discord.Rest
}
}
}
- public async Task RemovePermissionOverwriteAsync(IRole role)
+ public async Task RemovePermissionOverwriteAsync(IRole role, RequestOptions options = null)
{
- await ChannelHelper.RemovePermissionOverwriteAsync(this, Discord, role).ConfigureAwait(false);
+ await ChannelHelper.RemovePermissionOverwriteAsync(this, Discord, role, options).ConfigureAwait(false);
for (int i = 0; i < _overwrites.Length; i++)
{
@@ -111,41 +114,41 @@ namespace Discord.Rest
}
}
- public async Task> GetInvitesAsync()
- => await ChannelHelper.GetInvitesAsync(this, Discord);
- public async Task CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true)
- => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary);
+ public async Task> GetInvitesAsync(RequestOptions options = null)
+ => await ChannelHelper.GetInvitesAsync(this, Discord, options);
+ public async Task CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true, RequestOptions options = null)
+ => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, options);
public override string ToString() => Name;
//IGuildChannel
- async Task> IGuildChannel.GetInvitesAsync()
- => await GetInvitesAsync();
- async Task IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary)
- => await CreateInviteAsync(maxAge, maxUses, isTemporary);
+ async Task> IGuildChannel.GetInvitesAsync(RequestOptions options)
+ => await GetInvitesAsync(options);
+ async Task IGuildChannel.CreateInviteAsync(int? maxAge, int? maxUses, bool isTemporary, RequestOptions options)
+ => await CreateInviteAsync(maxAge, maxUses, isTemporary, options);
OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IRole role)
=> GetPermissionOverwrite(role);
OverwritePermissions? IGuildChannel.GetPermissionOverwrite(IUser user)
=> GetPermissionOverwrite(user);
- async Task IGuildChannel.AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions)
- => await AddPermissionOverwriteAsync(role, permissions);
- async Task IGuildChannel.AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions)
- => await AddPermissionOverwriteAsync(user, permissions);
- async Task IGuildChannel.RemovePermissionOverwriteAsync(IRole role)
- => await RemovePermissionOverwriteAsync(role);
- async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user)
- => await RemovePermissionOverwriteAsync(user);
+ async Task IGuildChannel.AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options)
+ => await AddPermissionOverwriteAsync(role, permissions, options);
+ async Task IGuildChannel.AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options)
+ => await AddPermissionOverwriteAsync(user, permissions, options);
+ async Task IGuildChannel.RemovePermissionOverwriteAsync(IRole role, RequestOptions options)
+ => await RemovePermissionOverwriteAsync(role, options);
+ async Task IGuildChannel.RemovePermissionOverwriteAsync(IUser user, RequestOptions options)
+ => await RemovePermissionOverwriteAsync(user, options);
- IAsyncEnumerable> IGuildChannel.GetUsersAsync(CacheMode mode)
+ IAsyncEnumerable> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> AsyncEnumerable.Empty>(); //Overriden //Overriden in Text/Voice //TODO: Does this actually override?
- Task IGuildChannel.GetUserAsync(ulong id, CacheMode mode)
+ Task IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult(null); //Overriden in Text/Voice //TODO: Does this actually override?
//IChannel
- IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode)
+ IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
=> AsyncEnumerable.Empty>(); //Overriden in Text/Voice //TODO: Does this actually override?
- Task IChannel.GetUserAsync(ulong id, CacheMode mode)
+ Task IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
=> Task.FromResult(null); //Overriden in Text/Voice //TODO: Does this actually override?
}
}
diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
index 77677a5bf..b90fff58f 100644
--- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
+++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
@@ -34,95 +34,95 @@ namespace Discord.Rest
}
- public Task ModifyAsync(Action func)
- => ChannelHelper.ModifyAsync(this, Discord, func);
+ public Task ModifyAsync(Action func, RequestOptions options = null)
+ => ChannelHelper.ModifyAsync(this, Discord, func, options);
- public Task GetUserAsync(ulong id)
- => ChannelHelper.GetUserAsync(this, Guild, Discord, id);
- public IAsyncEnumerable> GetUsersAsync()
- => ChannelHelper.GetUsersAsync(this, Guild, Discord);
+ public Task GetUserAsync(ulong id, RequestOptions options = null)
+ => ChannelHelper.GetUserAsync(this, Guild, Discord, id, options);
+ public IAsyncEnumerable> GetUsersAsync(RequestOptions options = null)
+ => ChannelHelper.GetUsersAsync(this, Guild, Discord, null, null, options);
- public Task GetMessageAsync(ulong id)
- => ChannelHelper.GetMessageAsync(this, Discord, id);
- public IAsyncEnumerable> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch)
- => ChannelHelper.GetMessagesAsync(this, Discord, limit: limit);
- public IAsyncEnumerable> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
- => ChannelHelper.GetMessagesAsync(this, Discord, fromMessageId, dir, limit);
- public IAsyncEnumerable> GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
- => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit);
- public Task> GetPinnedMessagesAsync()
- => ChannelHelper.GetPinnedMessagesAsync(this, Discord);
+ public Task