@@ -37,11 +37,12 @@ namespace Discord.Commands | |||
/// <summary> Requires the command to be invoked in the specified context. </summary> | |||
/// <param name="contexts">The type of context the command can be invoked in. Multiple contexts can be specified by ORing the contexts together.</param> | |||
/// <example> | |||
/// <code language="c#"> | |||
/// [Command("private_only")] | |||
/// <code language="cs"> | |||
/// [Command("secret")] | |||
/// [RequireContext(ContextType.DM | ContextType.Group)] | |||
/// public async Task PrivateOnly() | |||
/// public Task PrivateOnlyAsync() | |||
/// { | |||
/// return ReplyAsync("shhh, this command is a secret"); | |||
/// } | |||
/// </code> | |||
/// </example> | |||
@@ -50,12 +51,13 @@ namespace Discord.Commands | |||
Contexts = contexts; | |||
} | |||
/// <inheritdoc /> | |||
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) | |||
{ | |||
bool isValid = false; | |||
if ((Contexts & ContextType.Guild) != 0) | |||
isValid = isValid || context.Channel is IGuildChannel; | |||
isValid = context.Channel is IGuildChannel; | |||
if ((Contexts & ContextType.DM) != 0) | |||
isValid = isValid || context.Channel is IDMChannel; | |||
if ((Contexts & ContextType.Group) != 0) | |||
@@ -44,7 +44,7 @@ namespace Discord.Commands | |||
/// If this map is set to null or empty, the default delimiter of " will be used. | |||
/// </summary> | |||
/// <example> | |||
/// <code language="C#"> | |||
/// <code language="cs"> | |||
/// QuotationMarkAliasMap = new Dictionary<char, char%gt;() | |||
/// { | |||
/// {'\"', '\"' }, | |||
@@ -8,9 +8,12 @@ namespace Discord.Commands | |||
{ | |||
public Exception Exception { get; } | |||
/// <inheritdoc /> | |||
public CommandError? Error { get; } | |||
/// <inheritdoc /> | |||
public string ErrorReason { get; } | |||
/// <inheritdoc /> | |||
public bool IsSuccess => !Error.HasValue; | |||
private ExecuteResult(Exception exception, CommandError? error, string errorReason) | |||
@@ -11,6 +11,7 @@ namespace Discord.Audio | |||
public override bool CanSeek => false; | |||
public override bool CanWrite => false; | |||
/// <exception cref="InvalidOperationException">This stream does not accept headers.</exception> | |||
public virtual void WriteHeader(ushort seq, uint timestamp, bool missed) => | |||
throw new InvalidOperationException("This stream does not accept headers."); | |||
public override void Write(byte[] buffer, int offset, int count) | |||
@@ -1,5 +1,8 @@ | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// Represent a permission object. | |||
/// </summary> | |||
public struct Overwrite | |||
{ | |||
/// <summary> | |||
@@ -16,7 +19,7 @@ namespace Discord | |||
public OverwritePermissions Permissions { get; } | |||
/// <summary> | |||
/// Creates a new <see cref="Overwrite"/> with provided target information and modified permissions. | |||
/// Initializes a new <see cref="Overwrite"/> with provided target information and modified permissions. | |||
/// </summary> | |||
public Overwrite(ulong targetId, PermissionTarget targetType, OverwritePermissions permissions) | |||
{ | |||
@@ -4,6 +4,9 @@ using System.Diagnostics; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// Represents a container for a series of overwrite permissions. | |||
/// </summary> | |||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||
public struct OverwritePermissions | |||
{ | |||
@@ -14,11 +17,13 @@ namespace Discord | |||
/// <summary> | |||
/// Gets a <see cref="OverwritePermissions" /> that grants all permissions for the given channel. | |||
/// </summary> | |||
/// <exception cref="ArgumentException">Unknown channel type.</exception> | |||
public static OverwritePermissions AllowAll(IChannel channel) | |||
=> new OverwritePermissions(ChannelPermissions.All(channel).RawValue, 0); | |||
/// <summary> | |||
/// Gets a <see cref="OverwritePermissions" /> that denies all permissions for the given channel. | |||
/// </summary> | |||
/// <exception cref="ArgumentException">Unknown channel type.</exception> | |||
public static OverwritePermissions DenyAll(IChannel channel) | |||
=> new OverwritePermissions(0, ChannelPermissions.All(channel).RawValue); | |||
@@ -132,7 +137,7 @@ namespace Discord | |||
} | |||
/// <summary> | |||
/// Creates a new <see cref="ChannelPermissions" /> with the provided permissions. | |||
/// Initializes a new <see cref="ChannelPermissions"/> struct with the provided permissions. | |||
/// </summary> | |||
public OverwritePermissions( | |||
PermValue createInstantInvite = PermValue.Inherit, | |||
@@ -160,8 +165,8 @@ namespace Discord | |||
moveMembers, useVoiceActivation, manageRoles, manageWebhooks) { } | |||
/// <summary> | |||
/// Creates a new <see cref="OverwritePermissions" /> from this one, changing the provided non-null | |||
/// permissions. | |||
/// Initializes a new <see cref="OverwritePermissions" /> from the current one, changing the provided | |||
/// non-null permissions. | |||
/// </summary> | |||
public OverwritePermissions Modify( | |||
PermValue? createInstantInvite = null, | |||
@@ -14,45 +14,64 @@ namespace Discord | |||
{ | |||
/// <summary> Gets the default user color value. </summary> | |||
public static readonly Color Default = new Color(0); | |||
/// <summary> Gets the teal color value </summary> | |||
/// <summary> Gets the teal color value. </summary> | |||
public static readonly Color Teal = new Color(0x1ABC9C); | |||
/// <summary> Gets the dark teal color value </summary> | |||
/// <summary> Gets the dark teal color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/1ABC9C">1ABC9C</see>.</returns> | |||
public static readonly Color DarkTeal = new Color(0x11806A); | |||
/// <summary> Gets the green color value </summary> | |||
/// <summary> Gets the green color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/11806A">11806A</see>.</returns> | |||
public static readonly Color Green = new Color(0x2ECC71); | |||
/// <summary> Gets the dark green color value </summary> | |||
/// <summary> Gets the dark green color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/2ECC71">2ECC71</see>.</returns> | |||
public static readonly Color DarkGreen = new Color(0x1F8B4C); | |||
/// <summary> Gets the blue color value </summary> | |||
/// <summary> Gets the blue color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/1F8B4C">1F8B4C</see>.</returns> | |||
public static readonly Color Blue = new Color(0x3498DB); | |||
/// <summary> Gets the dark blue color value </summary> | |||
/// <summary> Gets the dark blue color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/3498DB">3498DB</see>.</returns> | |||
public static readonly Color DarkBlue = new Color(0x206694); | |||
/// <summary> Gets the purple color value </summary> | |||
/// <summary> Gets the purple color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/206694">206694</see>.</returns> | |||
public static readonly Color Purple = new Color(0x9B59B6); | |||
/// <summary> Gets the dark purple color value </summary> | |||
/// <summary> Gets the dark purple color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/9B59B6">9B59B6</see>.</returns> | |||
public static readonly Color DarkPurple = new Color(0x71368A); | |||
/// <summary> Gets the magenta color value </summary> | |||
/// <summary> Gets the magenta color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/71368A">71368A</see>.</returns> | |||
public static readonly Color Magenta = new Color(0xE91E63); | |||
/// <summary> Gets the dark magenta color value </summary> | |||
/// <summary> Gets the dark magenta color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/E91E63">E91E63</see>.</returns> | |||
public static readonly Color DarkMagenta = new Color(0xAD1457); | |||
/// <summary> Gets the gold color value </summary> | |||
/// <summary> Gets the gold color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/AD1457">AD1457</see>.</returns> | |||
public static readonly Color Gold = new Color(0xF1C40F); | |||
/// <summary> Gets the light orange color value </summary> | |||
/// <summary> Gets the light orange color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/F1C40F">F1C40F</see>.</returns> | |||
public static readonly Color LightOrange = new Color(0xC27C0E); | |||
/// <summary> Gets the orange color value </summary> | |||
/// <summary> Gets the orange color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/C27C0E">C27C0E</see>.</returns> | |||
public static readonly Color Orange = new Color(0xE67E22); | |||
/// <summary> Gets the dark orange color value </summary> | |||
/// <summary> Gets the dark orange color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/E67E22">E67E22</see>.</returns> | |||
public static readonly Color DarkOrange = new Color(0xA84300); | |||
/// <summary> Gets the red color value </summary> | |||
/// <summary> Gets the red color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/A84300">A84300</see>.</returns> | |||
public static readonly Color Red = new Color(0xE74C3C); | |||
/// <summary> Gets the dark red color value </summary> | |||
/// <summary> Gets the dark red color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/E74C3C">E74C3C</see>.</returns> | |||
public static readonly Color DarkRed = new Color(0x992D22); | |||
/// <summary> Gets the light grey color value </summary> | |||
/// <summary> Gets the light grey color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/992D22">992D22</see>.</returns> | |||
public static readonly Color LightGrey = new Color(0x979C9F); | |||
/// <summary> Gets the lighter grey color value </summary> | |||
/// <summary> Gets the lighter grey color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/979C9F">979C9F</see>.</returns> | |||
public static readonly Color LighterGrey = new Color(0x95A5A6); | |||
/// <summary> Gets the dark grey color value </summary> | |||
/// <summary> Gets the dark grey color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/95A5A6">95A5A6</see>.</returns> | |||
public static readonly Color DarkGrey = new Color(0x607D8B); | |||
/// <summary> Gets the darker grey color value </summary> | |||
/// <summary> Gets the darker grey color value. </summary> | |||
/// <returns> A color class with the hex value of <see href="http://www.color-hex.com/color/607D8B">607D8B</see>.</returns> | |||
public static readonly Color DarkerGrey = new Color(0x546E7A); | |||
/// <summary> Gets the encoded value for this color. </summary> | |||
@@ -66,13 +85,13 @@ namespace Discord | |||
public byte B => (byte)(RawValue); | |||
/// <summary> | |||
/// Initializes a <see cref="Color" /> <see langword="struct"/> with the given raw value. | |||
/// Initializes a <see cref="Color"/> struct with the given raw value. | |||
/// </summary> | |||
/// <example> | |||
/// The following will create a color that has a hex value of | |||
/// <see href="http://www.color-hex.com/color/607d8b">#607D8B</see>. | |||
/// <code language="cs"> | |||
/// Color darkGrey = new Color(0x607D8B); | |||
/// Color darkGrey = new Color(0x607D8B); | |||
/// </code> | |||
/// </example> | |||
/// <param name="rawValue">The raw value of the color (e.g. <c>0x607D8B</c>).</param> | |||
@@ -87,7 +106,7 @@ namespace Discord | |||
/// The following will create a color that has a value of | |||
/// <see href="http://www.color-hex.com/color/607d8b">#607D8B</see>. | |||
/// <code language="cs"> | |||
/// Color darkGrey = new Color((byte)0b_01100000, (byte)0b_01111101, (byte)0b_10001011); | |||
/// Color darkGrey = new Color((byte)0b_01100000, (byte)0b_01111101, (byte)0b_10001011); | |||
/// </code> | |||
/// </example> | |||
/// <param name="r">The byte that represents the red color.</param> | |||
@@ -108,7 +127,7 @@ namespace Discord | |||
/// The following will create a color that has a value of | |||
/// <see href="http://www.color-hex.com/color/607d8b">#607D8B</see>. | |||
/// <code language="cs"> | |||
/// Color darkGrey = new Color(96, 125, 139); | |||
/// Color darkGrey = new Color(96, 125, 139); | |||
/// </code> | |||
/// </example> | |||
/// <param name="r">The value that represents the red color. Must be within 0~255.</param> | |||
@@ -135,7 +154,7 @@ namespace Discord | |||
/// The following will create a color that has a value of | |||
/// <see href="http://www.color-hex.com/color/607c8c">#607c8c</see>. | |||
/// <code language="cs"> | |||
/// Color darkGrey = new Color(0.38f, 0.49f, 0.55f); | |||
/// Color darkGrey = new Color(0.38f, 0.49f, 0.55f); | |||
/// </code> | |||
/// </example> | |||
/// <param name="r">The value that represents the red color. Must be within 0~1.</param> | |||
@@ -11,54 +11,79 @@ namespace Discord | |||
/// <summary> | |||
/// Gets the guild owning this role. | |||
/// </summary> | |||
/// <returns> | |||
/// A guild representing the parent guild of this role. | |||
/// </returns> | |||
IGuild Guild { get; } | |||
/// <summary> | |||
/// Gets the color given to users of this role. | |||
/// </summary> | |||
/// <returns> | |||
/// A <see cref="Color"/> struct representing the color of this role. | |||
/// </returns> | |||
Color Color { get; } | |||
/// <summary> | |||
/// Determines whether the role can be separated in the user list. | |||
/// </summary> | |||
/// <returns> | |||
/// Returns <c>true</c> if users of this role are separated in the user list; otherwise, returns | |||
/// <c>false</c>. | |||
/// <c>true</c> if users of this role are separated in the user list; otherwise <c>false</c>. | |||
/// </returns> | |||
bool IsHoisted { get; } | |||
/// <summary> | |||
/// Determines whether the role is managed by Discord. | |||
/// </summary> | |||
/// <returns> | |||
/// Returns <c>true</c> if this role is automatically managed by Discord; otherwise, returns | |||
/// <c>false</c>. | |||
/// <c>true</c> if this role is automatically managed by Discord; otherwise <c>false</c>. | |||
/// </returns> | |||
bool IsManaged { get; } | |||
/// <summary> | |||
/// Determines whether the role is mentionable. | |||
/// </summary> | |||
/// <returns> | |||
/// Returns <c>true</c> if this role may be mentioned in messages; otherwise, returns | |||
/// <c>false</c>. | |||
/// <c>true</c> if this role may be mentioned in messages; otherwise <c>false</c>. | |||
/// </returns> | |||
bool IsMentionable { get; } | |||
/// <summary> | |||
/// Gets the name of this role. | |||
/// </summary> | |||
/// <returns> | |||
/// A string containing the name of this role. | |||
/// </returns> | |||
string Name { get; } | |||
/// <summary> | |||
/// Gets the permissions granted to members of this role. | |||
/// </summary> | |||
/// <returns> | |||
/// A <see cref="GuildPermissions"/> struct that this role possesses. | |||
/// </returns> | |||
GuildPermissions Permissions { get; } | |||
/// <summary> | |||
/// Gets this role's position relative to other roles in the same guild. | |||
/// </summary> | |||
/// <returns> | |||
/// An <see cref="int"/> representing the position of the role in the role list of the guild. | |||
/// </returns> | |||
int Position { get; } | |||
/// <summary> | |||
/// Modifies this role. | |||
/// </summary> | |||
/// <param name="func">The properties to modify the role with.</param> | |||
/// <example> | |||
/// <code language="cs"> | |||
/// await role.ModifyAsync(x => | |||
/// { | |||
/// x.Name = "Sonic"; | |||
/// x.Color = new Color(0x1A50BC); | |||
/// x.Mentionable = true; | |||
/// }); | |||
/// </code> | |||
/// </example> | |||
/// <param name="func">A delegate containing the properties to modify the role with.</param> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <returns> | |||
/// An awaitable <see cref="Task"/>. | |||
/// </returns> | |||
Task ModifyAsync(Action<RoleProperties> func, RequestOptions options = null); | |||
} | |||
} |
@@ -6,12 +6,18 @@ namespace Discord | |||
public class ReorderRoleProperties | |||
{ | |||
/// <summary> | |||
/// Gets the ID of the role to be edited. | |||
/// Gets the identifier of the role to be edited. | |||
/// </summary> | |||
/// <returns> | |||
/// A <see cref="ulong"/> representing the snowflake identifier of the role to be modified. | |||
/// </returns> | |||
public ulong Id { get; } | |||
/// <summary> | |||
/// Gets the new zero-based position of the role. | |||
/// </summary> | |||
/// <returns> | |||
/// A <see cref="int"/> representing the new zero-based position of the role. | |||
/// </returns> | |||
public int Position { get; } | |||
/// <summary> | |||
@@ -10,7 +10,7 @@ namespace Discord | |||
/// Gets or sets the name of the role. | |||
/// </summary> | |||
/// <remarks> | |||
/// If this role is the EveryoneRole, this value may not be set. | |||
/// This value may not be set if the role is an @everyone role. | |||
/// </remarks> | |||
public Optional<string> Name { get; set; } | |||
/// <summary> | |||
@@ -21,28 +21,28 @@ namespace Discord | |||
/// Gets or sets the position of the role. This is 0-based! | |||
/// </summary> | |||
/// <remarks> | |||
/// If this role is the EveryoneRole, this value may not be set. | |||
/// This value may not be set if the role is an @everyone role. | |||
/// </remarks> | |||
public Optional<int> Position { get; set; } | |||
/// <summary> | |||
/// Gets or sets the color of the role. | |||
/// </summary> | |||
/// <remarks> | |||
/// If this role is the EveryoneRole, this value may not be set. | |||
/// This value may not be set if the role is an @everyone role. | |||
/// </remarks> | |||
public Optional<Color> Color { get; set; } | |||
/// <summary> | |||
/// Gets or sets whether or not this role should be displayed independently in the user list. | |||
/// </summary> | |||
/// <remarks> | |||
/// If this role is the EveryoneRole, this value may not be set. | |||
/// This value may not be set if the role is an @everyone role. | |||
/// </remarks> | |||
public Optional<bool> Hoist { get; set; } | |||
/// <summary> | |||
/// Gets or sets whether or not this role can be mentioned. | |||
/// </summary> | |||
/// <remarks> | |||
/// If this role is the EveryoneRole, this value may not be set. | |||
/// This value may not be set if the role is an @everyone role. | |||
/// </remarks> | |||
public Optional<bool> Mentionable { get; set; } | |||
} | |||
@@ -14,10 +14,12 @@ namespace Discord | |||
builder.WithColor(new Color(r, g, b)); | |||
/// <summary> Adds embed color based on the provided RGB <see cref="int"/> value. </summary> | |||
/// <exception cref="ArgumentOutOfRangeException">The argument value is not between 0 to 255.</exception> | |||
public static EmbedBuilder WithColor(this EmbedBuilder builder, int r, int g, int b) => | |||
builder.WithColor(new Color(r, g, b)); | |||
/// <summary> Adds embed color based on the provided RGB <see cref="float"/> value. </summary> | |||
/// <exception cref="ArgumentOutOfRangeException">The argument value is not between 0 to 1.</exception> | |||
public static EmbedBuilder WithColor(this EmbedBuilder builder, float r, float g, float b) => | |||
builder.WithColor(new Color(r, g, b)); | |||
@@ -10,6 +10,7 @@ namespace Discord | |||
/// <summary> | |||
/// Sends a message via DM. | |||
/// </summary> | |||
/// <param name="user">The user to send the DM to.</param> | |||
/// <param name="text">The message to be sent.</param> | |||
/// <param name="isTTS">Whether the message should be read aloud by Discord or not.</param> | |||
/// <param name="embed">The <see cref="EmbedType.Rich"/> <see cref="Embed"/> to be sent.</param> | |||
@@ -29,6 +30,7 @@ namespace Discord | |||
/// <summary> | |||
/// Sends a file to this message channel with an optional caption. | |||
/// </summary> | |||
/// <param name="user">The user to send the DM to.</param> | |||
/// <param name="stream">The <see cref="Stream"/> of the file to be sent.</param> | |||
/// <param name="filename">The name of the attachment.</param> | |||
/// <param name="text">The message to be sent.</param> | |||
@@ -58,6 +60,7 @@ namespace Discord | |||
/// <summary> | |||
/// Sends a file via DM with an optional caption. | |||
/// </summary> | |||
/// <param name="user">The user to send the DM to.</param> | |||
/// <param name="filePath">The file path of the file.</param> | |||
/// <param name="text">The message to be sent.</param> | |||
/// <param name="isTTS">Whether the message should be read aloud by Discord or not.</param> | |||
@@ -89,6 +92,7 @@ namespace Discord | |||
/// The number of days to remove messages from this user for - must be between [0, 7] | |||
/// </param> | |||
/// <param name="reason">The reason of the ban to be written in the audit log.</param> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <exception cref="ArgumentException"><paramref name="pruneDays" /> is not between 0 to 7.</exception> | |||
public static Task BanAsync(this IGuildUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) | |||
=> user.Guild.AddBanAsync(user, pruneDays, reason, options); | |||
@@ -62,12 +62,12 @@ namespace Discord | |||
/// Gets a generic channel via the snowflake identifier. | |||
/// </summary> | |||
/// <example> | |||
/// <code lang="cs" title="Example method"> | |||
/// var channel = await _client.GetChannelAsync(381889909113225237); | |||
/// if (channel != null && channel is IMessageChannel msgChannel) | |||
/// { | |||
/// await msgChannel.SendMessageAsync($"{msgChannel} is created at {msgChannel.CreatedAt}"); | |||
/// } | |||
/// <code language="cs" title="Example method"> | |||
/// var channel = await _client.GetChannelAsync(381889909113225237); | |||
/// if (channel != null && channel is IMessageChannel msgChannel) | |||
/// { | |||
/// await msgChannel.SendMessageAsync($"{msgChannel} is created at {msgChannel.CreatedAt}"); | |||
/// } | |||
/// </code> | |||
/// </example> | |||
/// <param name="id">The snowflake identifier of the channel (e.g. `381889909113225237`).</param> | |||
@@ -150,10 +150,10 @@ namespace Discord | |||
/// Gets a user via the snowflake identifier. | |||
/// </summary> | |||
/// <example> | |||
/// <code lang="cs" title="Example method"> | |||
/// var user = await _client.GetUserAsync(168693960628371456); | |||
/// if (user != null) | |||
/// Console.WriteLine($"{user} is created at {user.CreatedAt}."; | |||
/// <code language="cs" title="Example method"> | |||
/// var user = await _client.GetUserAsync(168693960628371456); | |||
/// if (user != null) | |||
/// Console.WriteLine($"{user} is created at {user.CreatedAt}."; | |||
/// </code> | |||
/// </example> | |||
/// <param name="id">The snowflake identifier of the user (e.g. `168693960628371456`).</param> | |||
@@ -170,9 +170,9 @@ namespace Discord | |||
/// </summary> | |||
/// <example> | |||
/// <code language="cs" title="Example method"> | |||
/// var user = await _client.GetUserAsync("Still", "2876"); | |||
/// if (user != null) | |||
/// Console.WriteLine($"{user} is created at {user.CreatedAt}."; | |||
/// var user = await _client.GetUserAsync("Still", "2876"); | |||
/// if (user != null) | |||
/// Console.WriteLine($"{user} is created at {user.CreatedAt}."; | |||
/// </code> | |||
/// </example> | |||
/// <param name="username">The name of the user (e.g. `Still`).</param> | |||
@@ -45,6 +45,7 @@ namespace Discord.API | |||
internal IRestClient RestClient { get; private set; } | |||
internal ulong? CurrentUserId { get; set;} | |||
/// <exception cref="ArgumentException">Unknown OAuth token type.</exception> | |||
public DiscordRestApiClient(RestClientProvider restClientProvider, string userAgent, RetryMode defaultRetryMode = RetryMode.AlwaysRetry, | |||
JsonSerializer serializer = null) | |||
{ | |||
@@ -60,7 +61,6 @@ namespace Discord.API | |||
} | |||
/// <exception cref="ArgumentException">Unknown OAuth token type.</exception> | |||
/// <exception cref="Exception">A delegate callback throws an exception.</exception> | |||
internal void SetBaseUrl(string baseUrl) | |||
{ | |||
RestClient = _restClientProvider(baseUrl); | |||
@@ -5,13 +5,24 @@ using System.Threading.Tasks; | |||
namespace Discord.Rest | |||
{ | |||
/// <summary> | |||
/// Provides a client to send REST-based requests to Discord. | |||
/// </summary> | |||
public class DiscordRestClient : BaseDiscordClient, IDiscordClient | |||
{ | |||
private RestApplication _applicationInfo; | |||
/// <summary> | |||
/// Gets the logged-in user. | |||
/// </summary> | |||
public new RestSelfUser CurrentUser => base.CurrentUser as RestSelfUser; | |||
/// <inheritdoc /> | |||
public DiscordRestClient() : this(new DiscordRestConfig()) { } | |||
/// <summary> | |||
/// Initializes a new <see cref="DiscordRestClient"/> with the provided configuratation. | |||
/// </summary> | |||
/// <param name="config">The configuration to be used with the client.</param> | |||
public DiscordRestClient(DiscordRestConfig config) : base(config, CreateApiClient(config)) { } | |||
private static API.DiscordRestApiClient CreateApiClient(DiscordRestConfig config) | |||