| @@ -4917,7 +4917,11 @@ | |||||
| Present if this option is a group or subcommand. | Present if this option is a group or subcommand. | ||||
| </summary> | </summary> | ||||
| </member> | </member> | ||||
| <!-- Badly formed XML comment ignored for member "T:Discord.IApplicationCommandOption" --> | |||||
| <member name="T:Discord.IApplicationCommandOption"> | |||||
| <summary> | |||||
| Options for the <see cref="T:Discord.IApplicationCommand"/>, see <see href="https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption">The docs</see>. | |||||
| </summary> | |||||
| </member> | |||||
| <member name="P:Discord.IApplicationCommandOption.Type"> | <member name="P:Discord.IApplicationCommandOption.Type"> | ||||
| <summary> | <summary> | ||||
| The type of this <see cref="T:Discord.IApplicationCommandOption"/>. | The type of this <see cref="T:Discord.IApplicationCommandOption"/>. | ||||
| @@ -5318,7 +5322,7 @@ | |||||
| <summary> | <summary> | ||||
| Builds this builder into a <see cref="T:Discord.MessageComponent"/> used to send your components. | Builds this builder into a <see cref="T:Discord.MessageComponent"/> used to send your components. | ||||
| </summary> | </summary> | ||||
| <returns>A <see cref="T:Discord.MessageComponent"/> that can be sent with <see cref="!:IMessageChannel.SendMessageAsync(string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent)"/>.</returns> | |||||
| <returns>A <see cref="T:Discord.MessageComponent"/> that can be sent with <see cref="M:Discord.IMessageChannel.SendMessageAsync(System.String,System.Boolean,Discord.Embed,Discord.RequestOptions,Discord.AllowedMentions,Discord.MessageReference,Discord.MessageComponent,Discord.ISticker[],Discord.Embed[])"/>.</returns> | |||||
| </member> | </member> | ||||
| <member name="T:Discord.ActionRowBuilder"> | <member name="T:Discord.ActionRowBuilder"> | ||||
| <summary> | <summary> | ||||
| @@ -6021,6 +6025,7 @@ | |||||
| <param name="description">The description of this option.</param> | <param name="description">The description of this option.</param> | ||||
| <param name="required">If this option is required for this command.</param> | <param name="required">If this option is required for this command.</param> | ||||
| <param name="isDefault">If this option is the default option.</param> | <param name="isDefault">If this option is the default option.</param> | ||||
| <param name="isAutocomplete">If this option is set to autocompleate.</param> | |||||
| <param name="options">The options of the option to add.</param> | <param name="options">The options of the option to add.</param> | ||||
| <param name="choices">The choices of this option.</param> | <param name="choices">The choices of this option.</param> | ||||
| <returns>The current builder.</returns> | <returns>The current builder.</returns> | ||||
| @@ -8262,7 +8267,7 @@ | |||||
| </member> | </member> | ||||
| <member name="P:Discord.ReactionMetadata.IsMe"> | <member name="P:Discord.ReactionMetadata.IsMe"> | ||||
| <summary> | <summary> | ||||
| Gets a value that indicates whether the current user has reacted to this. | |||||
| Gets a value that indicates whether the current user has reacted to | |||||
| </summary> | </summary> | ||||
| <returns> | <returns> | ||||
| <c>true</c> if the user has reacted to the message; otherwise <c>false</c>. | <c>true</c> if the user has reacted to the message; otherwise <c>false</c>. | ||||
| @@ -10266,7 +10271,7 @@ | |||||
| <example> | <example> | ||||
| <para>The following example checks if the current user has the ability to send a message with attachment in | <para>The following example checks if the current user has the ability to send a message with attachment in | ||||
| this channel; if so, uploads a file via <see cref="!:IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference)"/>.</para> | this channel; if so, uploads a file via <see cref="!:IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference)"/>.</para> | ||||
| <code language="cs"> | |||||
| <code language="cs"> | |||||
| if (currentUser?.GetPermissions(targetChannel)?.AttachFiles) | if (currentUser?.GetPermissions(targetChannel)?.AttachFiles) | ||||
| await targetChannel.SendFileAsync("fortnite.png"); | await targetChannel.SendFileAsync("fortnite.png"); | ||||
| </code> | </code> | ||||
| @@ -11086,6 +11091,7 @@ | |||||
| </code> | </code> | ||||
| </example> | </example> | ||||
| <param name="msg">The message to remove reactions from.</param> | <param name="msg">The message to remove reactions from.</param> | ||||
| <param name="user">The user who removed the reaction.</param> | |||||
| <param name="reactions">An array of reactions to remove from the message.</param> | <param name="reactions">An array of reactions to remove from the message.</param> | ||||
| <param name="options">The options to be used when sending the request.</param> | <param name="options">The options to be used when sending the request.</param> | ||||
| <returns> | <returns> | ||||
| @@ -11098,6 +11104,7 @@ | |||||
| <summary> | <summary> | ||||
| Sends an inline reply that references a message. | Sends an inline reply that references a message. | ||||
| </summary> | </summary> | ||||
| <param name="msg">The message that is being replyed on.</param> | |||||
| <param name="text">The message to be sent.</param> | <param name="text">The message to be sent.</param> | ||||
| <param name="isTTS">Determines whether the message should be read aloud by Discord or not.</param> | <param name="isTTS">Determines whether the message should be read aloud by Discord or not.</param> | ||||
| <param name="embed">The <see cref="F:Discord.EmbedType.Rich"/> <see cref="T:Discord.Embed"/> to be sent.</param> | <param name="embed">The <see cref="F:Discord.EmbedType.Rich"/> <see cref="T:Discord.Embed"/> to be sent.</param> | ||||
| @@ -11107,6 +11114,8 @@ | |||||
| If <c>null</c>, all mentioned roles and users will be notified. | If <c>null</c>, all mentioned roles and users will be notified. | ||||
| </param> | </param> | ||||
| <param name="options">The options to be used when sending the request.</param> | <param name="options">The options to be used when sending the request.</param> | ||||
| <param name="components">The message components to be included with this message. Used for interactions.</param> | |||||
| <param name="stickers">A collection of stickers to send with the message.</param> | |||||
| <returns> | <returns> | ||||
| A task that represents an asynchronous send operation for delivering the message. The task result | A task that represents an asynchronous send operation for delivering the message. The task result | ||||
| contains the sent message. | contains the sent message. | ||||
| @@ -11184,6 +11193,7 @@ | |||||
| <param name="isTTS">Whether the message should be read aloud by Discord or not.</param> | <param name="isTTS">Whether the message should be read aloud by Discord or not.</param> | ||||
| <param name="embed">The <see cref="F:Discord.EmbedType.Rich"/> <see cref="T:Discord.Embed"/> to be sent.</param> | <param name="embed">The <see cref="F:Discord.EmbedType.Rich"/> <see cref="T:Discord.Embed"/> to be sent.</param> | ||||
| <param name="options">The options to be used when sending the request.</param> | <param name="options">The options to be used when sending the request.</param> | ||||
| <param name="component">The message component to be included with this message. Used for interactions.</param> | |||||
| <returns> | <returns> | ||||
| A task that represents an asynchronous send operation for delivering the message. The task result | A task that represents an asynchronous send operation for delivering the message. The task result | ||||
| contains the sent message. | contains the sent message. | ||||
| @@ -11231,6 +11241,7 @@ | |||||
| <param name="isTTS">Whether the message should be read aloud by Discord or not.</param> | <param name="isTTS">Whether the message should be read aloud by Discord or not.</param> | ||||
| <param name="embed">The <see cref="F:Discord.EmbedType.Rich"/> <see cref="T:Discord.Embed"/> to be sent.</param> | <param name="embed">The <see cref="F:Discord.EmbedType.Rich"/> <see cref="T:Discord.Embed"/> to be sent.</param> | ||||
| <param name="options">The options to be used when sending the request.</param> | <param name="options">The options to be used when sending the request.</param> | ||||
| <param name="component">The message component to be included with this message. Used for interactions.</param> | |||||
| <returns> | <returns> | ||||
| A task that represents an asynchronous send operation for delivering the message. The task result | A task that represents an asynchronous send operation for delivering the message. The task result | ||||
| contains the sent message. | contains the sent message. | ||||
| @@ -11825,12 +11836,8 @@ | |||||
| <summary> | <summary> | ||||
| Initializes a new instance of the <see cref="T:Discord.Net.ApplicationCommandException" /> class. | Initializes a new instance of the <see cref="T:Discord.Net.ApplicationCommandException" /> class. | ||||
| </summary> | </summary> | ||||
| <param name="request">The request that was sent prior to the exception.</param> | |||||
| <param name="requestJson"></param> | <param name="requestJson"></param> | ||||
| <param name="httpError"></param> | <param name="httpError"></param> | ||||
| <param name="discordCode">The Discord status code returned.</param> | |||||
| <param name="reason">The reason behind the exception.</param> | |||||
| <param name="errors"></param> | |||||
| </member> | </member> | ||||
| <member name="T:Discord.Net.BucketId"> | <member name="T:Discord.Net.BucketId"> | ||||
| <summary> | <summary> | ||||
| @@ -33,10 +33,10 @@ namespace Discord | |||||
| internal AutocompleteOption(ApplicationCommandOptionType type, string name, object value, bool focused) | internal AutocompleteOption(ApplicationCommandOptionType type, string name, object value, bool focused) | ||||
| { | { | ||||
| this.Type = type; | |||||
| this.Name = name; | |||||
| this.Value = value; | |||||
| this.Focused = focused; | |||||
| Type = type; | |||||
| Name = name; | |||||
| Value = value; | |||||
| Focused = focused; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -83,8 +83,8 @@ namespace Discord | |||||
| /// <exception cref="ArgumentException"/> | /// <exception cref="ArgumentException"/> | ||||
| public AutocompleteResult(string name, object value) | public AutocompleteResult(string name, object value) | ||||
| { | { | ||||
| this.Name = name; | |||||
| this.Value = value; | |||||
| Name = name; | |||||
| Value = value; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -53,8 +53,8 @@ namespace Discord | |||||
| { | { | ||||
| MessageCommandProperties props = new MessageCommandProperties() | MessageCommandProperties props = new MessageCommandProperties() | ||||
| { | { | ||||
| Name = this.Name, | |||||
| DefaultPermission = this.DefaultPermission | |||||
| Name = Name, | |||||
| DefaultPermission = DefaultPermission | |||||
| }; | }; | ||||
| return props; | return props; | ||||
| @@ -70,7 +70,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public MessageCommandBuilder WithName(string name) | public MessageCommandBuilder WithName(string name) | ||||
| { | { | ||||
| this.Name = name; | |||||
| Name = name; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -81,7 +81,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public MessageCommandBuilder WithDefaultPermission (bool value) | public MessageCommandBuilder WithDefaultPermission (bool value) | ||||
| { | { | ||||
| this.DefaultPermission = value; | |||||
| DefaultPermission = value; | |||||
| return this; | return this; | ||||
| } | } | ||||
| } | } | ||||
| @@ -51,8 +51,8 @@ namespace Discord | |||||
| { | { | ||||
| UserCommandProperties props = new UserCommandProperties() | UserCommandProperties props = new UserCommandProperties() | ||||
| { | { | ||||
| Name = this.Name, | |||||
| DefaultPermission = this.DefaultPermission | |||||
| Name = Name, | |||||
| DefaultPermission = DefaultPermission | |||||
| }; | }; | ||||
| return props; | return props; | ||||
| @@ -68,7 +68,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public UserCommandBuilder WithName(string name) | public UserCommandBuilder WithName(string name) | ||||
| { | { | ||||
| this.Name = name; | |||||
| Name = name; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -79,7 +79,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public UserCommandBuilder WithDefaultPermission (bool value) | public UserCommandBuilder WithDefaultPermission (bool value) | ||||
| { | { | ||||
| this.DefaultPermission = value; | |||||
| DefaultPermission = value; | |||||
| return this; | return this; | ||||
| } | } | ||||
| } | } | ||||
| @@ -25,7 +25,7 @@ namespace Discord | |||||
| internal ActionRowComponent() { } | internal ActionRowComponent() { } | ||||
| internal ActionRowComponent(List<IMessageComponent> components) | internal ActionRowComponent(List<IMessageComponent> components) | ||||
| { | { | ||||
| this.Components = components; | |||||
| Components = components; | |||||
| } | } | ||||
| string IMessageComponent.CustomId => null; | string IMessageComponent.CustomId => null; | ||||
| @@ -55,16 +55,16 @@ namespace Discord | |||||
| /// A newly created button builder with the same properties as this button. | /// A newly created button builder with the same properties as this button. | ||||
| /// </returns> | /// </returns> | ||||
| public ButtonBuilder ToBuilder() | public ButtonBuilder ToBuilder() | ||||
| => new ButtonBuilder(this.Label, this.CustomId, this.Style, this.Url, this.Emote, this.Disabled); | |||||
| => new ButtonBuilder(Label, CustomId, Style, Url, Emote, Disabled); | |||||
| internal ButtonComponent(ButtonStyle style, string label, IEmote emote, string customId, string url, bool disabled) | internal ButtonComponent(ButtonStyle style, string label, IEmote emote, string customId, string url, bool disabled) | ||||
| { | { | ||||
| this.Style = style; | |||||
| this.Label = label; | |||||
| this.Emote = emote; | |||||
| this.CustomId = customId; | |||||
| this.Url = url; | |||||
| this.Disabled = disabled; | |||||
| Style = style; | |||||
| Label = label; | |||||
| Emote = emote; | |||||
| CustomId = customId; | |||||
| Url = url; | |||||
| Disabled = disabled; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -69,14 +69,14 @@ namespace Discord | |||||
| switch (component) | switch (component) | ||||
| { | { | ||||
| case ButtonComponent button: | case ButtonComponent button: | ||||
| this.WithButton(button.Label, button.CustomId, button.Style, button.Emote, button.Url, button.Disabled, row); | |||||
| WithButton(button.Label, button.CustomId, button.Style, button.Emote, button.Url, button.Disabled, row); | |||||
| break; | break; | ||||
| case ActionRowComponent actionRow: | case ActionRowComponent actionRow: | ||||
| foreach (var cmp in actionRow.Components) | foreach (var cmp in actionRow.Components) | ||||
| AddComponent(cmp, row); | AddComponent(cmp, row); | ||||
| break; | break; | ||||
| case SelectMenuComponent menu: | case SelectMenuComponent menu: | ||||
| this.WithSelectMenu(menu.Placeholder, menu.CustomId, menu.Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)).ToList(), menu.Placeholder, menu.MinValues, menu.MaxValues, menu.Disabled, row); | |||||
| WithSelectMenu(menu.Placeholder, menu.CustomId, menu.Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)).ToList(), menu.Placeholder, menu.MinValues, menu.MaxValues, menu.Disabled, row); | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| @@ -187,7 +187,7 @@ namespace Discord | |||||
| .WithUrl(url) | .WithUrl(url) | ||||
| .WithDisabled(disabled); | .WithDisabled(disabled); | ||||
| return this.WithButton(button, row); | |||||
| return WithButton(button, row); | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -245,8 +245,8 @@ namespace Discord | |||||
| /// <returns>A <see cref="MessageComponent"/> that can be sent with <see cref="IMessageChannel.SendMessageAsync"/>.</returns> | /// <returns>A <see cref="MessageComponent"/> that can be sent with <see cref="IMessageChannel.SendMessageAsync"/>.</returns> | ||||
| public MessageComponent Build() | public MessageComponent Build() | ||||
| { | { | ||||
| if (this._actionRows != null) | |||||
| return new MessageComponent(this._actionRows.Select(x => x.Build()).ToList()); | |||||
| if (_actionRows != null) | |||||
| return new MessageComponent(_actionRows.Select(x => x.Build()).ToList()); | |||||
| else | else | ||||
| return MessageComponent.Empty; | return MessageComponent.Empty; | ||||
| } | } | ||||
| @@ -295,7 +295,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public ActionRowBuilder WithComponents(List<IMessageComponent> components) | public ActionRowBuilder WithComponents(List<IMessageComponent> components) | ||||
| { | { | ||||
| this.Components = components; | |||||
| Components = components; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -307,10 +307,10 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public ActionRowBuilder AddComponent(IMessageComponent component) | public ActionRowBuilder AddComponent(IMessageComponent component) | ||||
| { | { | ||||
| if (this.Components.Count >= MaxChildCount) | |||||
| if (Components.Count >= MaxChildCount) | |||||
| throw new InvalidOperationException($"Components count reached {MaxChildCount}"); | throw new InvalidOperationException($"Components count reached {MaxChildCount}"); | ||||
| this.Components.Add(component); | |||||
| Components.Add(component); | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -320,7 +320,7 @@ namespace Discord | |||||
| /// <returns>A <see cref="ActionRowComponent"/> that can be used within a <see cref="ComponentBuilder"/></returns> | /// <returns>A <see cref="ActionRowComponent"/> that can be used within a <see cref="ComponentBuilder"/></returns> | ||||
| public ActionRowComponent Build() | public ActionRowComponent Build() | ||||
| { | { | ||||
| return new ActionRowComponent(this._components); | |||||
| return new ActionRowComponent(_components); | |||||
| } | } | ||||
| internal bool CanTakeComponent(IMessageComponent component) | internal bool CanTakeComponent(IMessageComponent component) | ||||
| @@ -330,12 +330,12 @@ namespace Discord | |||||
| case ComponentType.ActionRow: | case ComponentType.ActionRow: | ||||
| return false; | return false; | ||||
| case ComponentType.Button: | case ComponentType.Button: | ||||
| if (this.Components.Any(x => x.Type == ComponentType.SelectMenu)) | |||||
| if (Components.Any(x => x.Type == ComponentType.SelectMenu)) | |||||
| return false; | return false; | ||||
| else | else | ||||
| return this.Components.Count < 5; | |||||
| return Components.Count < 5; | |||||
| case ComponentType.SelectMenu: | case ComponentType.SelectMenu: | ||||
| return this.Components.Count == 0; | |||||
| return Components.Count == 0; | |||||
| default: | default: | ||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -435,12 +435,12 @@ namespace Discord | |||||
| /// <param name="disabled">Disabled this button or not.</param> | /// <param name="disabled">Disabled this button or not.</param> | ||||
| public ButtonBuilder(string label = null, string customId = null, ButtonStyle style = ButtonStyle.Primary, string url = null, IEmote emote = null, bool disabled = false) | public ButtonBuilder(string label = null, string customId = null, ButtonStyle style = ButtonStyle.Primary, string url = null, IEmote emote = null, bool disabled = false) | ||||
| { | { | ||||
| this.CustomId = customId; | |||||
| this.Style = style; | |||||
| this.Url = url; | |||||
| this.Label = label; | |||||
| this.Disabled = disabled; | |||||
| this.Emote = emote; | |||||
| CustomId = customId; | |||||
| Style = style; | |||||
| Url = url; | |||||
| Label = label; | |||||
| Disabled = disabled; | |||||
| Emote = emote; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -448,12 +448,12 @@ namespace Discord | |||||
| /// </summary> | /// </summary> | ||||
| public ButtonBuilder(ButtonComponent button) | public ButtonBuilder(ButtonComponent button) | ||||
| { | { | ||||
| this.CustomId = button.CustomId; | |||||
| this.Style = button.Style; | |||||
| this.Url = button.Url; | |||||
| this.Label = button.Label; | |||||
| this.Disabled = button.Disabled; | |||||
| this.Emote = button.Emote; | |||||
| CustomId = button.CustomId; | |||||
| Style = button.Style; | |||||
| Url = button.Url; | |||||
| Label = button.Label; | |||||
| Disabled = button.Disabled; | |||||
| Emote = button.Emote; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -514,7 +514,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public ButtonBuilder WithLabel(string label) | public ButtonBuilder WithLabel(string label) | ||||
| { | { | ||||
| this.Label = label; | |||||
| Label = label; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -525,7 +525,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public ButtonBuilder WithStyle(ButtonStyle style) | public ButtonBuilder WithStyle(ButtonStyle style) | ||||
| { | { | ||||
| this.Style = style; | |||||
| Style = style; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -536,7 +536,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public ButtonBuilder WithEmote(IEmote emote) | public ButtonBuilder WithEmote(IEmote emote) | ||||
| { | { | ||||
| this.Emote = emote; | |||||
| Emote = emote; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -547,7 +547,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public ButtonBuilder WithUrl(string url) | public ButtonBuilder WithUrl(string url) | ||||
| { | { | ||||
| this.Url = url; | |||||
| Url = url; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -559,7 +559,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public ButtonBuilder WithCustomId(string id) | public ButtonBuilder WithCustomId(string id) | ||||
| { | { | ||||
| this.CustomId = id; | |||||
| CustomId = id; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -570,7 +570,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public ButtonBuilder WithDisabled(bool disabled) | public ButtonBuilder WithDisabled(bool disabled) | ||||
| { | { | ||||
| this.Disabled = disabled; | |||||
| Disabled = disabled; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -585,23 +585,23 @@ namespace Discord | |||||
| /// <exception cref="InvalidOperationException">A non-link button must contain a custom id</exception> | /// <exception cref="InvalidOperationException">A non-link button must contain a custom id</exception> | ||||
| public ButtonComponent Build() | public ButtonComponent Build() | ||||
| { | { | ||||
| if (string.IsNullOrEmpty(this.Label) && this.Emote == null) | |||||
| if (string.IsNullOrEmpty(Label) && Emote == null) | |||||
| throw new InvalidOperationException("A button must have an Emote or a label!"); | throw new InvalidOperationException("A button must have an Emote or a label!"); | ||||
| if (!(string.IsNullOrEmpty(this.Url) ^ string.IsNullOrEmpty(this.CustomId))) | |||||
| if (!(string.IsNullOrEmpty(Url) ^ string.IsNullOrEmpty(CustomId))) | |||||
| throw new InvalidOperationException("A button must contain either a URL or a CustomId, but not both!"); | throw new InvalidOperationException("A button must contain either a URL or a CustomId, but not both!"); | ||||
| if (this.Style == ButtonStyle.Link) | |||||
| if (Style == ButtonStyle.Link) | |||||
| { | { | ||||
| if (string.IsNullOrEmpty(this.Url)) | |||||
| if (string.IsNullOrEmpty(Url)) | |||||
| throw new InvalidOperationException("Link buttons must have a link associated with them"); | throw new InvalidOperationException("Link buttons must have a link associated with them"); | ||||
| else | else | ||||
| UrlValidation.Validate(this.Url); | |||||
| UrlValidation.Validate(Url); | |||||
| } | } | ||||
| else if (string.IsNullOrEmpty(this.CustomId)) | |||||
| else if (string.IsNullOrEmpty(CustomId)) | |||||
| throw new InvalidOperationException("Non-link buttons must have a custom id associated with them"); | throw new InvalidOperationException("Non-link buttons must have a custom id associated with them"); | ||||
| return new ButtonComponent(this.Style, this.Label, this.Emote, this.CustomId, this.Url, this.Disabled); | |||||
| return new ButtonComponent(Style, Label, Emote, CustomId, Url, Disabled); | |||||
| } | } | ||||
| } | } | ||||
| @@ -736,12 +736,12 @@ namespace Discord | |||||
| /// </summary> | /// </summary> | ||||
| public SelectMenuBuilder(SelectMenuComponent selectMenu) | public SelectMenuBuilder(SelectMenuComponent selectMenu) | ||||
| { | { | ||||
| this.Placeholder = selectMenu.Placeholder; | |||||
| this.CustomId = selectMenu.Placeholder; | |||||
| this.MaxValues = selectMenu.MaxValues; | |||||
| this.MinValues = selectMenu.MinValues; | |||||
| this.Disabled = selectMenu.Disabled; | |||||
| this.Options = selectMenu.Options? | |||||
| Placeholder = selectMenu.Placeholder; | |||||
| CustomId = selectMenu.Placeholder; | |||||
| MaxValues = selectMenu.MaxValues; | |||||
| MinValues = selectMenu.MinValues; | |||||
| Disabled = selectMenu.Disabled; | |||||
| Options = selectMenu.Options? | |||||
| .Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)) | .Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)) | ||||
| .ToList(); | .ToList(); | ||||
| } | } | ||||
| @@ -757,12 +757,12 @@ namespace Discord | |||||
| /// <param name="disabled">Disabled this select menu or not.</param> | /// <param name="disabled">Disabled this select menu or not.</param> | ||||
| public SelectMenuBuilder(string customId, List<SelectMenuOptionBuilder> options, string placeholder = null, int maxValues = 1, int minValues = 1, bool disabled = false) | public SelectMenuBuilder(string customId, List<SelectMenuOptionBuilder> options, string placeholder = null, int maxValues = 1, int minValues = 1, bool disabled = false) | ||||
| { | { | ||||
| this.CustomId = customId; | |||||
| this.Options = options; | |||||
| this.Placeholder = placeholder; | |||||
| this.Disabled = disabled; | |||||
| this.MaxValues = maxValues; | |||||
| this.MinValues = minValues; | |||||
| CustomId = customId; | |||||
| Options = options; | |||||
| Placeholder = placeholder; | |||||
| Disabled = disabled; | |||||
| MaxValues = maxValues; | |||||
| MinValues = minValues; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -775,7 +775,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuBuilder WithCustomId(string customId) | public SelectMenuBuilder WithCustomId(string customId) | ||||
| { | { | ||||
| this.CustomId = customId; | |||||
| CustomId = customId; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -789,7 +789,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuBuilder WithPlaceholder(string placeholder) | public SelectMenuBuilder WithPlaceholder(string placeholder) | ||||
| { | { | ||||
| this.Placeholder = placeholder; | |||||
| Placeholder = placeholder; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -803,7 +803,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuBuilder WithMinValues(int minValues) | public SelectMenuBuilder WithMinValues(int minValues) | ||||
| { | { | ||||
| this.MinValues = minValues; | |||||
| MinValues = minValues; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -817,7 +817,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuBuilder WithMaxValues(int maxValues) | public SelectMenuBuilder WithMaxValues(int maxValues) | ||||
| { | { | ||||
| this.MaxValues = maxValues; | |||||
| MaxValues = maxValues; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -831,7 +831,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuBuilder WithOptions(List<SelectMenuOptionBuilder> options) | public SelectMenuBuilder WithOptions(List<SelectMenuOptionBuilder> options) | ||||
| { | { | ||||
| this.Options = options; | |||||
| Options = options; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -845,10 +845,10 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuBuilder AddOption(SelectMenuOptionBuilder option) | public SelectMenuBuilder AddOption(SelectMenuOptionBuilder option) | ||||
| { | { | ||||
| if (this.Options.Count >= MaxOptionCount) | |||||
| if (Options.Count >= MaxOptionCount) | |||||
| throw new InvalidOperationException($"Options count reached {MaxOptionCount}."); | throw new InvalidOperationException($"Options count reached {MaxOptionCount}."); | ||||
| this.Options.Add(option); | |||||
| Options.Add(option); | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -879,7 +879,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuBuilder WithDisabled(bool disabled) | public SelectMenuBuilder WithDisabled(bool disabled) | ||||
| { | { | ||||
| this.Disabled = disabled; | |||||
| Disabled = disabled; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -889,9 +889,9 @@ namespace Discord | |||||
| /// <returns>The newly built <see cref="SelectMenuComponent"/></returns> | /// <returns>The newly built <see cref="SelectMenuComponent"/></returns> | ||||
| public SelectMenuComponent Build() | public SelectMenuComponent Build() | ||||
| { | { | ||||
| var options = this.Options?.Select(x => x.Build()).ToList(); | |||||
| var options = Options?.Select(x => x.Build()).ToList(); | |||||
| return new SelectMenuComponent(this.CustomId, options, this.Placeholder, this.MinValues, this.MaxValues, this.Disabled); | |||||
| return new SelectMenuComponent(CustomId, options, Placeholder, MinValues, MaxValues, Disabled); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1012,11 +1012,11 @@ namespace Discord | |||||
| /// <param name="default">Render this option as selected by default or not.</param> | /// <param name="default">Render this option as selected by default or not.</param> | ||||
| public SelectMenuOptionBuilder(string label, string value, string description = null, IEmote emote = null, bool? @default = null) | public SelectMenuOptionBuilder(string label, string value, string description = null, IEmote emote = null, bool? @default = null) | ||||
| { | { | ||||
| this.Label = label; | |||||
| this.Value = value; | |||||
| this.Description = description; | |||||
| this.Emote = emote; | |||||
| this.Default = @default; | |||||
| Label = label; | |||||
| Value = value; | |||||
| Description = description; | |||||
| Emote = emote; | |||||
| Default = @default; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -1024,11 +1024,11 @@ namespace Discord | |||||
| /// </summary> | /// </summary> | ||||
| public SelectMenuOptionBuilder(SelectMenuOption option) | public SelectMenuOptionBuilder(SelectMenuOption option) | ||||
| { | { | ||||
| this.Label = option.Label; | |||||
| this.Value = option.Value; | |||||
| this.Description = option.Description; | |||||
| this.Emote = option.Emote; | |||||
| this.Default = option.Default; | |||||
| Label = option.Label; | |||||
| Value = option.Value; | |||||
| Description = option.Description; | |||||
| Emote = option.Emote; | |||||
| Default = option.Default; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -1041,7 +1041,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuOptionBuilder WithLabel(string label) | public SelectMenuOptionBuilder WithLabel(string label) | ||||
| { | { | ||||
| this.Label = label; | |||||
| Label = label; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -1055,7 +1055,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuOptionBuilder WithValue(string value) | public SelectMenuOptionBuilder WithValue(string value) | ||||
| { | { | ||||
| this.Value = value; | |||||
| Value = value; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -1069,7 +1069,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuOptionBuilder WithDescription(string description) | public SelectMenuOptionBuilder WithDescription(string description) | ||||
| { | { | ||||
| this.Description = description; | |||||
| Description = description; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -1082,7 +1082,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuOptionBuilder WithEmote(IEmote emote) | public SelectMenuOptionBuilder WithEmote(IEmote emote) | ||||
| { | { | ||||
| this.Emote = emote; | |||||
| Emote = emote; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -1095,7 +1095,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuOptionBuilder WithDefault(bool defaultValue) | public SelectMenuOptionBuilder WithDefault(bool defaultValue) | ||||
| { | { | ||||
| this.Default = defaultValue; | |||||
| Default = defaultValue; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -1105,7 +1105,7 @@ namespace Discord | |||||
| /// <returns>The newly built <see cref="SelectMenuOption"/>.</returns> | /// <returns>The newly built <see cref="SelectMenuOption"/>.</returns> | ||||
| public SelectMenuOption Build() | public SelectMenuOption Build() | ||||
| { | { | ||||
| return new SelectMenuOption(this.Label, this.Value, this.Description, this.Emote, this.Default); | |||||
| return new SelectMenuOption(Label, Value, Description, Emote, Default); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -18,7 +18,7 @@ namespace Discord | |||||
| internal MessageComponent(List<ActionRowComponent> components) | internal MessageComponent(List<ActionRowComponent> components) | ||||
| { | { | ||||
| this.Components = components; | |||||
| Components = components; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -52,21 +52,21 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SelectMenuBuilder ToBuilder() | public SelectMenuBuilder ToBuilder() | ||||
| => new SelectMenuBuilder( | => new SelectMenuBuilder( | ||||
| this.CustomId, | |||||
| this.Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)).ToList(), | |||||
| this.Placeholder, | |||||
| this.MaxValues, | |||||
| this.MinValues, | |||||
| this.Disabled); | |||||
| CustomId, | |||||
| Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)).ToList(), | |||||
| Placeholder, | |||||
| MaxValues, | |||||
| MinValues, | |||||
| Disabled); | |||||
| internal SelectMenuComponent(string customId, List<SelectMenuOption> options, string placeholder, int minValues, int maxValues, bool disabled) | internal SelectMenuComponent(string customId, List<SelectMenuOption> options, string placeholder, int minValues, int maxValues, bool disabled) | ||||
| { | { | ||||
| this.CustomId = customId; | |||||
| this.Options = options; | |||||
| this.Placeholder = placeholder; | |||||
| this.MinValues = minValues; | |||||
| this.MaxValues = maxValues; | |||||
| this.Disabled = disabled; | |||||
| CustomId = customId; | |||||
| Options = options; | |||||
| Placeholder = placeholder; | |||||
| MinValues = minValues; | |||||
| MaxValues = maxValues; | |||||
| Disabled = disabled; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -38,11 +38,11 @@ namespace Discord | |||||
| internal SelectMenuOption(string label, string value, string description, IEmote emote, bool? defaultValue) | internal SelectMenuOption(string label, string value, string description, IEmote emote, bool? defaultValue) | ||||
| { | { | ||||
| this.Label = label; | |||||
| this.Value = value; | |||||
| this.Description = description; | |||||
| this.Emote = emote; | |||||
| this.Default = defaultValue; | |||||
| Label = label; | |||||
| Value = value; | |||||
| Description = description; | |||||
| Emote = emote; | |||||
| Default = defaultValue; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -100,16 +100,16 @@ namespace Discord | |||||
| { | { | ||||
| SlashCommandProperties props = new SlashCommandProperties() | SlashCommandProperties props = new SlashCommandProperties() | ||||
| { | { | ||||
| Name = this.Name, | |||||
| Description = this.Description, | |||||
| DefaultPermission = this.DefaultPermission, | |||||
| Name = Name, | |||||
| Description = Description, | |||||
| DefaultPermission = DefaultPermission, | |||||
| }; | }; | ||||
| if (this.Options != null && this.Options.Any()) | |||||
| if (Options != null && Options.Any()) | |||||
| { | { | ||||
| var options = new List<ApplicationCommandOptionProperties>(); | var options = new List<ApplicationCommandOptionProperties>(); | ||||
| this.Options.ForEach(x => options.Add(x.Build())); | |||||
| Options.ForEach(x => options.Add(x.Build())); | |||||
| props.Options = options; | props.Options = options; | ||||
| } | } | ||||
| @@ -127,7 +127,7 @@ namespace Discord | |||||
| /// </returns> | /// </returns> | ||||
| public SlashCommandBuilder WithName(string name) | public SlashCommandBuilder WithName(string name) | ||||
| { | { | ||||
| this.Name = name; | |||||
| Name = name; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -138,7 +138,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public SlashCommandBuilder WithDescription(string description) | public SlashCommandBuilder WithDescription(string description) | ||||
| { | { | ||||
| this.Description = description; | |||||
| Description = description; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -149,7 +149,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public SlashCommandBuilder WithDefaultPermission(bool value) | public SlashCommandBuilder WithDefaultPermission(bool value) | ||||
| { | { | ||||
| this.DefaultPermission = value; | |||||
| DefaultPermission = value; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -186,8 +186,8 @@ namespace Discord | |||||
| // make sure theres only one option with default set to true | // make sure theres only one option with default set to true | ||||
| if (isDefault.HasValue && isDefault.Value) | if (isDefault.HasValue && isDefault.Value) | ||||
| { | { | ||||
| if (this.Options != null) | |||||
| if (this.Options.Any(x => x.Default.HasValue && x.Default.Value)) | |||||
| if (Options != null) | |||||
| if (Options.Any(x => x.Default.HasValue && x.Default.Value)) | |||||
| throw new ArgumentException("There can only be one command option with default set to true!", nameof(isDefault)); | throw new ArgumentException("There can only be one command option with default set to true!", nameof(isDefault)); | ||||
| } | } | ||||
| @@ -237,16 +237,16 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public SlashCommandBuilder AddOption(SlashCommandOptionBuilder option) | public SlashCommandBuilder AddOption(SlashCommandOptionBuilder option) | ||||
| { | { | ||||
| if (this.Options == null) | |||||
| this.Options = new List<SlashCommandOptionBuilder>(); | |||||
| if (Options == null) | |||||
| Options = new List<SlashCommandOptionBuilder>(); | |||||
| if (this.Options.Count >= MaxOptionsCount) | |||||
| if (Options.Count >= MaxOptionsCount) | |||||
| throw new ArgumentOutOfRangeException(nameof(Options), $"Cannot have more than {MaxOptionsCount} options!"); | throw new ArgumentOutOfRangeException(nameof(Options), $"Cannot have more than {MaxOptionsCount} options!"); | ||||
| if (option == null) | if (option == null) | ||||
| throw new ArgumentNullException(nameof(option), "Option cannot be null"); | throw new ArgumentNullException(nameof(option), "Option cannot be null"); | ||||
| this.Options.Add(option); | |||||
| Options.Add(option); | |||||
| return this; | return this; | ||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -262,13 +262,13 @@ namespace Discord | |||||
| if (options.Length == 0) | if (options.Length == 0) | ||||
| throw new ArgumentException(nameof(options), "Options cannot be empty!"); | throw new ArgumentException(nameof(options), "Options cannot be empty!"); | ||||
| if (this.Options == null) | |||||
| this.Options = new List<SlashCommandOptionBuilder>(); | |||||
| if (Options == null) | |||||
| Options = new List<SlashCommandOptionBuilder>(); | |||||
| if (this.Options.Count + options.Length > MaxOptionsCount) | |||||
| if (Options.Count + options.Length > MaxOptionsCount) | |||||
| throw new ArgumentOutOfRangeException(nameof(options), $"Cannot have more than {MaxOptionsCount} options!"); | throw new ArgumentOutOfRangeException(nameof(options), $"Cannot have more than {MaxOptionsCount} options!"); | ||||
| this.Options.AddRange(options); | |||||
| Options.AddRange(options); | |||||
| return this; | return this; | ||||
| } | } | ||||
| } | } | ||||
| @@ -365,7 +365,7 @@ namespace Discord | |||||
| /// <returns>The built version of this option.</returns> | /// <returns>The built version of this option.</returns> | ||||
| public ApplicationCommandOptionProperties Build() | public ApplicationCommandOptionProperties Build() | ||||
| { | { | ||||
| bool isSubType = this.Type == ApplicationCommandOptionType.SubCommandGroup; | |||||
| bool isSubType = Type == ApplicationCommandOptionType.SubCommandGroup; | |||||
| if (isSubType && (Options == null || !Options.Any())) | if (isSubType && (Options == null || !Options.Any())) | ||||
| throw new ArgumentException(nameof(Options), "SubCommands/SubCommandGroups must have at least one option"); | throw new ArgumentException(nameof(Options), "SubCommands/SubCommandGroups must have at least one option"); | ||||
| @@ -375,14 +375,14 @@ namespace Discord | |||||
| return new ApplicationCommandOptionProperties() | return new ApplicationCommandOptionProperties() | ||||
| { | { | ||||
| Name = this.Name, | |||||
| Description = this.Description, | |||||
| Default = this.Default, | |||||
| Required = this.Required, | |||||
| Type = this.Type, | |||||
| Options = this.Options?.Count > 0 ? new List<ApplicationCommandOptionProperties>(this.Options.Select(x => x.Build())) : null, | |||||
| Choices = this.Choices, | |||||
| Autocomplete = this.Autocomplete | |||||
| Name = Name, | |||||
| Description = Description, | |||||
| Default = Default, | |||||
| Required = Required, | |||||
| Type = Type, | |||||
| Options = Options?.Count > 0 ? new List<ApplicationCommandOptionProperties>(Options.Select(x => x.Build())) : null, | |||||
| Choices = Choices, | |||||
| Autocomplete = Autocomplete | |||||
| }; | }; | ||||
| } | } | ||||
| @@ -418,8 +418,8 @@ namespace Discord | |||||
| // make sure theres only one option with default set to true | // make sure theres only one option with default set to true | ||||
| if (isDefault) | if (isDefault) | ||||
| { | { | ||||
| if (this.Options != null) | |||||
| if (this.Options.Any(x => x.Default.HasValue && x.Default.Value)) | |||||
| if (Options != null) | |||||
| if (Options.Any(x => x.Default.HasValue && x.Default.Value)) | |||||
| throw new ArgumentException("There can only be one command option with default set to true!", nameof(isDefault)); | throw new ArgumentException("There can only be one command option with default set to true!", nameof(isDefault)); | ||||
| } | } | ||||
| @@ -443,10 +443,10 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public SlashCommandOptionBuilder AddOption(SlashCommandOptionBuilder option) | public SlashCommandOptionBuilder AddOption(SlashCommandOptionBuilder option) | ||||
| { | { | ||||
| if (this.Options == null) | |||||
| this.Options = new List<SlashCommandOptionBuilder>(); | |||||
| if (Options == null) | |||||
| Options = new List<SlashCommandOptionBuilder>(); | |||||
| if (this.Options.Count >= SlashCommandBuilder.MaxOptionsCount) | |||||
| if (Options.Count >= SlashCommandBuilder.MaxOptionsCount) | |||||
| throw new ArgumentOutOfRangeException(nameof(Choices), $"There can only be {SlashCommandBuilder.MaxOptionsCount} options per sub command group!"); | throw new ArgumentOutOfRangeException(nameof(Choices), $"There can only be {SlashCommandBuilder.MaxOptionsCount} options per sub command group!"); | ||||
| if (option == null) | if (option == null) | ||||
| @@ -527,7 +527,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public SlashCommandOptionBuilder WithName(string name) | public SlashCommandOptionBuilder WithName(string name) | ||||
| { | { | ||||
| this.Name = name; | |||||
| Name = name; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -539,7 +539,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public SlashCommandOptionBuilder WithDescription(string description) | public SlashCommandOptionBuilder WithDescription(string description) | ||||
| { | { | ||||
| this.Description = description; | |||||
| Description = description; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -550,7 +550,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public SlashCommandOptionBuilder WithRequired(bool value) | public SlashCommandOptionBuilder WithRequired(bool value) | ||||
| { | { | ||||
| this.Required = value; | |||||
| Required = value; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -561,7 +561,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public SlashCommandOptionBuilder WithDefault(bool value) | public SlashCommandOptionBuilder WithDefault(bool value) | ||||
| { | { | ||||
| this.Default = value; | |||||
| Default = value; | |||||
| return this; | return this; | ||||
| } | } | ||||
| @@ -572,7 +572,7 @@ namespace Discord | |||||
| /// <returns>The current builder.</returns> | /// <returns>The current builder.</returns> | ||||
| public SlashCommandOptionBuilder WithType(ApplicationCommandOptionType type) | public SlashCommandOptionBuilder WithType(ApplicationCommandOptionType type) | ||||
| { | { | ||||
| this.Type = type; | |||||
| Type = type; | |||||
| return this; | return this; | ||||
| } | } | ||||
| } | } | ||||
| @@ -30,9 +30,9 @@ namespace Discord | |||||
| /// <param name="allow">The value of this permission.</param> | /// <param name="allow">The value of this permission.</param> | ||||
| public ApplicationCommandPermission(ulong targetId, ApplicationCommandPermissionTarget targetType, bool allow) | public ApplicationCommandPermission(ulong targetId, ApplicationCommandPermissionTarget targetType, bool allow) | ||||
| { | { | ||||
| this.TargetId = targetId; | |||||
| this.TargetType = targetType; | |||||
| this.Permission = allow; | |||||
| TargetId = targetId; | |||||
| TargetType = targetType; | |||||
| Permission = allow; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -42,9 +42,9 @@ namespace Discord | |||||
| /// <param name="allow">The value of this permission.</param> | /// <param name="allow">The value of this permission.</param> | ||||
| public ApplicationCommandPermission(IUser target, bool allow) | public ApplicationCommandPermission(IUser target, bool allow) | ||||
| { | { | ||||
| this.TargetId = target.Id; | |||||
| this.Permission = allow; | |||||
| this.TargetType = ApplicationCommandPermissionTarget.User; | |||||
| TargetId = target.Id; | |||||
| Permission = allow; | |||||
| TargetType = ApplicationCommandPermissionTarget.User; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -54,9 +54,9 @@ namespace Discord | |||||
| /// <param name="allow">The value of this permission.</param> | /// <param name="allow">The value of this permission.</param> | ||||
| public ApplicationCommandPermission(IRole target, bool allow) | public ApplicationCommandPermission(IRole target, bool allow) | ||||
| { | { | ||||
| this.TargetId = target.Id; | |||||
| this.Permission = allow; | |||||
| this.TargetType = ApplicationCommandPermissionTarget.Role; | |||||
| TargetId = target.Id; | |||||
| Permission = allow; | |||||
| TargetType = ApplicationCommandPermissionTarget.Role; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -34,10 +34,10 @@ namespace Discord | |||||
| internal GuildApplicationCommandPermission(ulong commandId, ulong appId, ulong guildId, ApplicationCommandPermission[] permissions) | internal GuildApplicationCommandPermission(ulong commandId, ulong appId, ulong guildId, ApplicationCommandPermission[] permissions) | ||||
| { | { | ||||
| this.CommandId = commandId; | |||||
| this.ApplicationId = appId; | |||||
| this.GuildId = guildId; | |||||
| this.Permissions = permissions; | |||||
| CommandId = commandId; | |||||
| ApplicationId = appId; | |||||
| GuildId = guildId; | |||||
| Permissions = permissions; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -50,14 +50,14 @@ namespace Discord | |||||
| internal StickerPack(string name, ulong id, ulong skuid, ulong? coverStickerId, string description, ulong bannerAssetId, IEnumerable<TSticker> stickers) | internal StickerPack(string name, ulong id, ulong skuid, ulong? coverStickerId, string description, ulong bannerAssetId, IEnumerable<TSticker> stickers) | ||||
| { | { | ||||
| this.Name = name; | |||||
| this.Id = id; | |||||
| this.SkuId = skuid; | |||||
| this.CoverStickerId = coverStickerId; | |||||
| this.Description = description; | |||||
| this.BannerAssetId = bannerAssetId; | |||||
| this.Stickers = stickers.ToImmutableArray(); | |||||
| Name = name; | |||||
| Id = id; | |||||
| SkuId = skuid; | |||||
| CoverStickerId = coverStickerId; | |||||
| Description = description; | |||||
| BannerAssetId = bannerAssetId; | |||||
| Stickers = stickers.ToImmutableArray(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -19,8 +19,8 @@ namespace Discord.API | |||||
| internal ActionRowComponent() { } | internal ActionRowComponent() { } | ||||
| internal ActionRowComponent(Discord.ActionRowComponent c) | internal ActionRowComponent(Discord.ActionRowComponent c) | ||||
| { | { | ||||
| this.Type = c.Type; | |||||
| this.Components = c.Components?.Select<IMessageComponent, IMessageComponent>(x => | |||||
| Type = c.Type; | |||||
| Components = c.Components?.Select<IMessageComponent, IMessageComponent>(x => | |||||
| { | { | ||||
| switch (x.Type) | switch (x.Type) | ||||
| { | { | ||||
| @@ -37,28 +37,28 @@ namespace Discord.API | |||||
| public ApplicationCommandOption(IApplicationCommandOption cmd) | public ApplicationCommandOption(IApplicationCommandOption cmd) | ||||
| { | { | ||||
| this.Choices = cmd.Choices.Select(x => new ApplicationCommandOptionChoice() | |||||
| Choices = cmd.Choices.Select(x => new ApplicationCommandOptionChoice() | |||||
| { | { | ||||
| Name = x.Name, | Name = x.Name, | ||||
| Value = x.Value | Value = x.Value | ||||
| }).ToArray(); | }).ToArray(); | ||||
| this.Options = cmd.Options.Select(x => new ApplicationCommandOption(x)).ToArray(); | |||||
| Options = cmd.Options.Select(x => new ApplicationCommandOption(x)).ToArray(); | |||||
| this.Required = cmd.Required.HasValue | |||||
| Required = cmd.Required.HasValue | |||||
| ? cmd.Required.Value | ? cmd.Required.Value | ||||
| : Optional<bool>.Unspecified; | : Optional<bool>.Unspecified; | ||||
| this.Default = cmd.Default.HasValue | |||||
| Default = cmd.Default.HasValue | |||||
| ? cmd.Default.Value | ? cmd.Default.Value | ||||
| : Optional<bool>.Unspecified; | : Optional<bool>.Unspecified; | ||||
| this.Name = cmd.Name; | |||||
| this.Type = cmd.Type; | |||||
| this.Description = cmd.Description; | |||||
| Name = cmd.Name; | |||||
| Type = cmd.Type; | |||||
| Description = cmd.Description; | |||||
| } | } | ||||
| public ApplicationCommandOption(Discord.ApplicationCommandOptionProperties option) | public ApplicationCommandOption(Discord.ApplicationCommandOptionProperties option) | ||||
| { | { | ||||
| this.Choices = option.Choices != null | |||||
| Choices = option.Choices != null | |||||
| ? option.Choices.Select(x => new ApplicationCommandOptionChoice() | ? option.Choices.Select(x => new ApplicationCommandOptionChoice() | ||||
| { | { | ||||
| Name = x.Name, | Name = x.Name, | ||||
| @@ -66,22 +66,22 @@ namespace Discord.API | |||||
| }).ToArray() | }).ToArray() | ||||
| : Optional<ApplicationCommandOptionChoice[]>.Unspecified; | : Optional<ApplicationCommandOptionChoice[]>.Unspecified; | ||||
| this.Options = option.Options != null | |||||
| Options = option.Options != null | |||||
| ? option.Options.Select(x => new ApplicationCommandOption(x)).ToArray() | ? option.Options.Select(x => new ApplicationCommandOption(x)).ToArray() | ||||
| : Optional<ApplicationCommandOption[]>.Unspecified; | : Optional<ApplicationCommandOption[]>.Unspecified; | ||||
| this.Required = option.Required.HasValue | |||||
| Required = option.Required.HasValue | |||||
| ? option.Required.Value | ? option.Required.Value | ||||
| : Optional<bool>.Unspecified; | : Optional<bool>.Unspecified; | ||||
| this.Default = option.Default.HasValue | |||||
| Default = option.Default.HasValue | |||||
| ? option.Default.Value | ? option.Default.Value | ||||
| : Optional<bool>.Unspecified; | : Optional<bool>.Unspecified; | ||||
| this.Name = option.Name; | |||||
| this.Type = option.Type; | |||||
| this.Description = option.Description; | |||||
| this.Autocomplete = option.Autocomplete; | |||||
| Name = option.Name; | |||||
| Type = option.Type; | |||||
| Description = option.Description; | |||||
| Autocomplete = option.Autocomplete; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -34,18 +34,18 @@ namespace Discord.API | |||||
| public ButtonComponent(Discord.ButtonComponent c) | public ButtonComponent(Discord.ButtonComponent c) | ||||
| { | { | ||||
| this.Type = c.Type; | |||||
| this.Style = c.Style; | |||||
| this.Label = c.Label; | |||||
| this.CustomId = c.CustomId; | |||||
| this.Url = c.Url; | |||||
| this.Disabled = c.Disabled; | |||||
| Type = c.Type; | |||||
| Style = c.Style; | |||||
| Label = c.Label; | |||||
| CustomId = c.CustomId; | |||||
| Url = c.Url; | |||||
| Disabled = c.Disabled; | |||||
| if (c.Emote != null) | if (c.Emote != null) | ||||
| { | { | ||||
| if (c.Emote is Emote e) | if (c.Emote is Emote e) | ||||
| { | { | ||||
| this.Emote = new Emoji() | |||||
| Emote = new Emoji() | |||||
| { | { | ||||
| Name = e.Name, | Name = e.Name, | ||||
| Animated = e.Animated, | Animated = e.Animated, | ||||
| @@ -54,7 +54,7 @@ namespace Discord.API | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| this.Emote = new Emoji() | |||||
| Emote = new Emoji() | |||||
| { | { | ||||
| Name = c.Emote.Name | Name = c.Emote.Name | ||||
| }; | }; | ||||
| @@ -63,6 +63,6 @@ namespace Discord.API | |||||
| } | } | ||||
| [JsonIgnore] | [JsonIgnore] | ||||
| string IMessageComponent.CustomId => this.CustomId.GetValueOrDefault(); | |||||
| string IMessageComponent.CustomId => CustomId.GetValueOrDefault(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -34,13 +34,13 @@ namespace Discord.API | |||||
| public SelectMenuComponent(Discord.SelectMenuComponent component) | public SelectMenuComponent(Discord.SelectMenuComponent component) | ||||
| { | { | ||||
| this.Type = component.Type; | |||||
| this.CustomId = component.CustomId; | |||||
| this.Options = component.Options.Select(x => new SelectMenuOption(x)).ToArray(); | |||||
| this.Placeholder = component.Placeholder; | |||||
| this.MinValues = component.MinValues; | |||||
| this.MaxValues = component.MaxValues; | |||||
| this.Disabled = component.Disabled; | |||||
| Type = component.Type; | |||||
| CustomId = component.CustomId; | |||||
| Options = component.Options.Select(x => new SelectMenuOption(x)).ToArray(); | |||||
| Placeholder = component.Placeholder; | |||||
| MinValues = component.MinValues; | |||||
| MaxValues = component.MaxValues; | |||||
| Disabled = component.Disabled; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -28,15 +28,15 @@ namespace Discord.API | |||||
| public SelectMenuOption(Discord.SelectMenuOption option) | public SelectMenuOption(Discord.SelectMenuOption option) | ||||
| { | { | ||||
| this.Label = option.Label; | |||||
| this.Value = option.Value; | |||||
| this.Description = option.Description; | |||||
| Label = option.Label; | |||||
| Value = option.Value; | |||||
| Description = option.Description; | |||||
| if (option.Emote != null) | if (option.Emote != null) | ||||
| { | { | ||||
| if (option.Emote is Emote e) | if (option.Emote is Emote e) | ||||
| { | { | ||||
| this.Emoji = new Emoji() | |||||
| Emoji = new Emoji() | |||||
| { | { | ||||
| Name = e.Name, | Name = e.Name, | ||||
| Animated = e.Animated, | Animated = e.Animated, | ||||
| @@ -45,14 +45,14 @@ namespace Discord.API | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| this.Emoji = new Emoji() | |||||
| Emoji = new Emoji() | |||||
| { | { | ||||
| Name = option.Emote.Name | Name = option.Emote.Name | ||||
| }; | }; | ||||
| } | } | ||||
| } | } | ||||
| this.Default = option.Default.HasValue ? option.Default.Value : Optional<bool>.Unspecified; | |||||
| Default = option.Default.HasValue ? option.Default.Value : Optional<bool>.Unspecified; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -12,7 +12,7 @@ namespace Discord.Net.Rest | |||||
| { | { | ||||
| Stream = stream; | Stream = stream; | ||||
| Filename = filename; | Filename = filename; | ||||
| this.ContentType = contentType; | |||||
| ContentType = contentType; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -28,10 +28,10 @@ namespace Discord.API.Rest | |||||
| public CreateApplicationCommandParams() { } | public CreateApplicationCommandParams() { } | ||||
| public CreateApplicationCommandParams(string name, string description, ApplicationCommandType type, ApplicationCommandOption[] options = null) | public CreateApplicationCommandParams(string name, string description, ApplicationCommandType type, ApplicationCommandOption[] options = null) | ||||
| { | { | ||||
| this.Name = name; | |||||
| this.Description = description; | |||||
| this.Options = Optional.Create<ApplicationCommandOption[]>(options); | |||||
| this.Type = type; | |||||
| Name = name; | |||||
| Description = description; | |||||
| Options = Optional.Create<ApplicationCommandOption[]>(options); | |||||
| Type = type; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1134,7 +1134,7 @@ namespace Discord.API | |||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{this.CurrentUserId}/commands", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentUserId}/commands", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> GetGlobalApplicationCommandAsync(ulong id, RequestOptions options = null) | public async Task<ApplicationCommand> GetGlobalApplicationCommandAsync(ulong id, RequestOptions options = null) | ||||
| @@ -1145,7 +1145,7 @@ namespace Discord.API | |||||
| try | try | ||||
| { | { | ||||
| return await SendAsync<ApplicationCommand>("GET", () => $"applications/{this.CurrentUserId}/commands/{id}", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| return await SendAsync<ApplicationCommand>("GET", () => $"applications/{CurrentUserId}/commands/{id}", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| catch(HttpException x) when (x.HttpCode == HttpStatusCode.NotFound) { return null; } | catch(HttpException x) when (x.HttpCode == HttpStatusCode.NotFound) { return null; } | ||||
| } | } | ||||
| @@ -1165,38 +1165,38 @@ namespace Discord.API | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{this.CurrentUserId}/commands", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{CurrentUserId}/commands", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> ModifyGlobalApplicationCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | public async Task<ApplicationCommand> ModifyGlobalApplicationCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> ModifyGlobalApplicationUserCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | public async Task<ApplicationCommand> ModifyGlobalApplicationUserCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> ModifyGlobalApplicationMessageCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | public async Task<ApplicationCommand> ModifyGlobalApplicationMessageCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task DeleteGlobalApplicationCommandAsync(ulong commandId, RequestOptions options = null) | public async Task DeleteGlobalApplicationCommandAsync(ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| await SendAsync("DELETE", () => $"applications/{this.CurrentUserId}/commands/{commandId}", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| await SendAsync("DELETE", () => $"applications/{CurrentUserId}/commands/{commandId}", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand[]> BulkOverwriteGlobalApplicationCommandsAsync(CreateApplicationCommandParams[] commands, RequestOptions options = null) | public async Task<ApplicationCommand[]> BulkOverwriteGlobalApplicationCommandsAsync(CreateApplicationCommandParams[] commands, RequestOptions options = null) | ||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{this.CurrentUserId}/commands", commands, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{CurrentUserId}/commands", commands, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand[]> GetGuildApplicationCommandsAsync(ulong guildId, RequestOptions options = null) | public async Task<ApplicationCommand[]> GetGuildApplicationCommandsAsync(ulong guildId, RequestOptions options = null) | ||||
| @@ -1205,7 +1205,7 @@ namespace Discord.API | |||||
| var bucket = new BucketIds(guildId: guildId); | var bucket = new BucketIds(guildId: guildId); | ||||
| return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", bucket, options: options).ConfigureAwait(false); | |||||
| return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands", bucket, options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> GetGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) | public async Task<ApplicationCommand> GetGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) | ||||
| @@ -1216,7 +1216,7 @@ namespace Discord.API | |||||
| try | try | ||||
| { | { | ||||
| return await SendAsync<ApplicationCommand>("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options); | |||||
| return await SendAsync<ApplicationCommand>("GET", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options); | |||||
| } | } | ||||
| catch(HttpException x) when (x.HttpCode == HttpStatusCode.NotFound) { return null; } | catch(HttpException x) when (x.HttpCode == HttpStatusCode.NotFound) { return null; } | ||||
| } | } | ||||
| @@ -1238,7 +1238,7 @@ namespace Discord.API | |||||
| var bucket = new BucketIds(guildId: guildId); | var bucket = new BucketIds(guildId: guildId); | ||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", command, bucket, options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands", command, bucket, options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> ModifyGuildApplicationCommandAsync(ModifyApplicationCommandParams command, ulong guildId, ulong commandId, RequestOptions options = null) | public async Task<ApplicationCommand> ModifyGuildApplicationCommandAsync(ModifyApplicationCommandParams command, ulong guildId, ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| @@ -1246,7 +1246,7 @@ namespace Discord.API | |||||
| var bucket = new BucketIds(guildId: guildId); | var bucket = new BucketIds(guildId: guildId); | ||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task DeleteGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) | public async Task DeleteGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| @@ -1254,7 +1254,7 @@ namespace Discord.API | |||||
| var bucket = new BucketIds(guildId: guildId); | var bucket = new BucketIds(guildId: guildId); | ||||
| await SendAsync<ApplicationCommand>("DELETE", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options).ConfigureAwait(false); | |||||
| await SendAsync<ApplicationCommand>("DELETE", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand[]> BulkOverwriteGuildApplicationCommandsAsync(ulong guildId, CreateApplicationCommandParams[] commands, RequestOptions options = null) | public async Task<ApplicationCommand[]> BulkOverwriteGuildApplicationCommandsAsync(ulong guildId, CreateApplicationCommandParams[] commands, RequestOptions options = null) | ||||
| @@ -1263,7 +1263,7 @@ namespace Discord.API | |||||
| var bucket = new BucketIds(guildId: guildId); | var bucket = new BucketIds(guildId: guildId); | ||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", commands, bucket, options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands", commands, bucket, options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| #endregion | #endregion | ||||
| @@ -1283,19 +1283,19 @@ namespace Discord.API | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await SendAsync<Message>("GET", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| return await SendAsync<Message>("GET", () => $"webhooks/{CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<Message> ModifyInteractionResponseAsync(ModifyInteractionResponseParams args, string interactionToken, RequestOptions options = null) | public async Task<Message> ModifyInteractionResponseAsync(ModifyInteractionResponseParams args, string interactionToken, RequestOptions options = null) | ||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", args, new BucketIds(), options: options); | |||||
| return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{CurrentUserId}/{interactionToken}/messages/@original", args, new BucketIds(), options: options); | |||||
| } | } | ||||
| public async Task DeleteInteractionResponseAsync(string interactionToken, RequestOptions options = null) | public async Task DeleteInteractionResponseAsync(string interactionToken, RequestOptions options = null) | ||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| await SendAsync("DELETE", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options); | |||||
| await SendAsync("DELETE", () => $"webhooks/{CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options); | |||||
| } | } | ||||
| public async Task<Message> CreateInteractionFollowupMessageAsync(CreateWebhookMessageParams args, string token, RequestOptions options = null) | public async Task<Message> CreateInteractionFollowupMessageAsync(CreateWebhookMessageParams args, string token, RequestOptions options = null) | ||||
| @@ -1345,7 +1345,7 @@ namespace Discord.API | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await SendAsync<GuildApplicationCommandPermission[]>("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/permissions", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| return await SendAsync<GuildApplicationCommandPermission[]>("GET", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/permissions", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<GuildApplicationCommandPermission> GetGuildApplicationCommandPermissionAsync(ulong guildId, ulong commandId, RequestOptions options = null) | public async Task<GuildApplicationCommandPermission> GetGuildApplicationCommandPermissionAsync(ulong guildId, ulong commandId, RequestOptions options = null) | ||||
| @@ -1355,7 +1355,7 @@ namespace Discord.API | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await SendAsync<GuildApplicationCommandPermission>("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| return await SendAsync<GuildApplicationCommandPermission>("GET", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<GuildApplicationCommandPermission> ModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissionsParams permissions, ulong guildId, ulong commandId, RequestOptions options = null) | public async Task<GuildApplicationCommandPermission> ModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissionsParams permissions, ulong guildId, ulong commandId, RequestOptions options = null) | ||||
| @@ -1365,7 +1365,7 @@ namespace Discord.API | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await SendJsonAsync<GuildApplicationCommandPermission>("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); | |||||
| return await SendJsonAsync<GuildApplicationCommandPermission>("PUT", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<IReadOnlyCollection<GuildApplicationCommandPermission>> BatchModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissions[] permissions, ulong guildId, RequestOptions options = null) | public async Task<IReadOnlyCollection<GuildApplicationCommandPermission>> BatchModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissions[] permissions, ulong guildId, RequestOptions options = null) | ||||
| @@ -1375,7 +1375,7 @@ namespace Discord.API | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await SendJsonAsync<GuildApplicationCommandPermission[]>("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); | |||||
| return await SendJsonAsync<GuildApplicationCommandPermission[]>("PUT", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| #endregion | #endregion | ||||
| @@ -39,18 +39,18 @@ namespace Discord.Rest | |||||
| internal void Update(StageInstance model, bool isLive = false) | internal void Update(StageInstance model, bool isLive = false) | ||||
| { | { | ||||
| this.Live = isLive; | |||||
| Live = isLive; | |||||
| if(isLive) | if(isLive) | ||||
| { | { | ||||
| this.Topic = model.Topic; | |||||
| this.PrivacyLevel = model.PrivacyLevel; | |||||
| this.DiscoverableDisabled = model.DiscoverableDisabled; | |||||
| Topic = model.Topic; | |||||
| PrivacyLevel = model.PrivacyLevel; | |||||
| DiscoverableDisabled = model.DiscoverableDisabled; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| this.Topic = null; | |||||
| this.PrivacyLevel = null; | |||||
| this.DiscoverableDisabled = null; | |||||
| Topic = null; | |||||
| PrivacyLevel = null; | |||||
| DiscoverableDisabled = null; | |||||
| } | } | ||||
| } | } | ||||
| @@ -67,7 +67,7 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new API.Rest.CreateStageInstanceParams() | var args = new API.Rest.CreateStageInstanceParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| PrivacyLevel = privacyLevel, | PrivacyLevel = privacyLevel, | ||||
| Topic = topic | Topic = topic | ||||
| }; | }; | ||||
| @@ -80,7 +80,7 @@ namespace Discord.Rest | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public async Task StopStageAsync(RequestOptions options = null) | public async Task StopStageAsync(RequestOptions options = null) | ||||
| { | { | ||||
| await Discord.ApiClient.DeleteStageInstanceAsync(this.Id, options); | |||||
| await Discord.ApiClient.DeleteStageInstanceAsync(Id, options); | |||||
| Update(null, false); | Update(null, false); | ||||
| } | } | ||||
| @@ -90,7 +90,7 @@ namespace Discord.Rest | |||||
| { | { | ||||
| await base.UpdateAsync(options); | await base.UpdateAsync(options); | ||||
| var model = await Discord.ApiClient.GetStageInstanceAsync(this.Id, options); | |||||
| var model = await Discord.ApiClient.GetStageInstanceAsync(Id, options); | |||||
| Update(model, model != null); | Update(model, model != null); | ||||
| } | } | ||||
| @@ -100,10 +100,10 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new API.Rest.ModifyVoiceStateParams() | var args = new API.Rest.ModifyVoiceStateParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| RequestToSpeakTimestamp = DateTimeOffset.UtcNow | RequestToSpeakTimestamp = DateTimeOffset.UtcNow | ||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | |||||
| return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -111,10 +111,10 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new API.Rest.ModifyVoiceStateParams() | var args = new API.Rest.ModifyVoiceStateParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| Suppressed = false | Suppressed = false | ||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | |||||
| return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -122,10 +122,10 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new API.Rest.ModifyVoiceStateParams() | var args = new API.Rest.ModifyVoiceStateParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| Suppressed = true | Suppressed = true | ||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | |||||
| return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -133,11 +133,11 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new API.Rest.ModifyVoiceStateParams() | var args = new API.Rest.ModifyVoiceStateParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| Suppressed = false | Suppressed = false | ||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); | |||||
| return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -145,11 +145,11 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new API.Rest.ModifyVoiceStateParams() | var args = new API.Rest.ModifyVoiceStateParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| Suppressed = true | Suppressed = true | ||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); | |||||
| return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -261,7 +261,7 @@ namespace Discord.Rest | |||||
| ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, RequestOptions options = null) | ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, RequestOptions options = null) | ||||
| { | { | ||||
| var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, options); | var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, options); | ||||
| return RestThreadChannel.Create(Discord, this.Guild, model); | |||||
| return RestThreadChannel.Create(Discord, Guild, model); | |||||
| } | } | ||||
| #endregion | #endregion | ||||
| @@ -58,21 +58,21 @@ namespace Discord.Rest | |||||
| { | { | ||||
| base.Update(model); | base.Update(model); | ||||
| this.Joined = model.ThreadMember.IsSpecified; | |||||
| Joined = model.ThreadMember.IsSpecified; | |||||
| if (model.ThreadMetadata.IsSpecified) | if (model.ThreadMetadata.IsSpecified) | ||||
| { | { | ||||
| this.Archived = model.ThreadMetadata.Value.Archived; | |||||
| this.AutoArchiveDuration = model.ThreadMetadata.Value.AutoArchiveDuration; | |||||
| this.ArchiveTimestamp = model.ThreadMetadata.Value.ArchiveTimestamp; | |||||
| this.Locked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false); | |||||
| Archived = model.ThreadMetadata.Value.Archived; | |||||
| AutoArchiveDuration = model.ThreadMetadata.Value.AutoArchiveDuration; | |||||
| ArchiveTimestamp = model.ThreadMetadata.Value.ArchiveTimestamp; | |||||
| Locked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false); | |||||
| } | } | ||||
| this.MemberCount = model.MemberCount.GetValueOrDefault(0); | |||||
| this.MessageCount = model.MessageCount.GetValueOrDefault(0); | |||||
| this.Type = (ThreadType)model.Type; | |||||
| this.ParentChannelId = model.CategoryId.Value; | |||||
| MemberCount = model.MemberCount.GetValueOrDefault(0); | |||||
| MessageCount = model.MessageCount.GetValueOrDefault(0); | |||||
| Type = (ThreadType)model.Type; | |||||
| ParentChannelId = model.CategoryId.Value; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -213,18 +213,18 @@ namespace Discord.Rest | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public Task JoinAsync(RequestOptions options = null) | public Task JoinAsync(RequestOptions options = null) | ||||
| => Discord.ApiClient.JoinThreadAsync(this.Id, options); | |||||
| => Discord.ApiClient.JoinThreadAsync(Id, options); | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public Task LeaveAsync(RequestOptions options = null) | public Task LeaveAsync(RequestOptions options = null) | ||||
| => Discord.ApiClient.LeaveThreadAsync(this.Id, options); | |||||
| => Discord.ApiClient.LeaveThreadAsync(Id, options); | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public Task AddUserAsync(IGuildUser user, RequestOptions options = null) | public Task AddUserAsync(IGuildUser user, RequestOptions options = null) | ||||
| => Discord.ApiClient.AddThreadMemberAsync(this.Id, user.Id, options); | |||||
| => Discord.ApiClient.AddThreadMemberAsync(Id, user.Id, options); | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public Task RemoveUserAsync(IGuildUser user, RequestOptions options = null) | public Task RemoveUserAsync(IGuildUser user, RequestOptions options = null) | ||||
| => Discord.ApiClient.RemoveThreadMemberAsync(this.Id, user.Id, options); | |||||
| => Discord.ApiClient.RemoveThreadMemberAsync(Id, user.Id, options); | |||||
| } | } | ||||
| } | } | ||||
| @@ -290,7 +290,7 @@ namespace Discord.Rest | |||||
| /// A task that represents the asynchronous delete operation. | /// A task that represents the asynchronous delete operation. | ||||
| /// </returns> | /// </returns> | ||||
| public Task DeleteSlashCommandsAsync(RequestOptions options = null) | public Task DeleteSlashCommandsAsync(RequestOptions options = null) | ||||
| => InteractionHelper.DeleteAllGuildCommandsAsync(Discord, this.Id, options); | |||||
| => InteractionHelper.DeleteAllGuildCommandsAsync(Discord, Id, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of slash commands created by the current user in this guild. | /// Gets a collection of slash commands created by the current user in this guild. | ||||
| @@ -933,7 +933,7 @@ namespace Discord.Rest | |||||
| /// if found, otherwise <see langword="null"/>. | /// if found, otherwise <see langword="null"/>. | ||||
| /// </returns> | /// </returns> | ||||
| public async Task<RestGuildCommand> GetApplicationCommandAsync(ulong id, RequestOptions options = null) | public async Task<RestGuildCommand> GetApplicationCommandAsync(ulong id, RequestOptions options = null) | ||||
| => await ClientHelper.GetGuildApplicationCommand(Discord, id, this.Id, options); | |||||
| => await ClientHelper.GetGuildApplicationCommand(Discord, id, Id, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Creates an application command within this guild. | /// Creates an application command within this guild. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -944,9 +944,9 @@ namespace Discord.Rest | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<RestGuildCommand> CreateApplicationCommandAsync(ApplicationCommandProperties properties, RequestOptions options = null) | public async Task<RestGuildCommand> CreateApplicationCommandAsync(ApplicationCommandProperties properties, RequestOptions options = null) | ||||
| { | { | ||||
| var model = await InteractionHelper.CreateGuildCommand(Discord, this.Id, properties, options); | |||||
| var model = await InteractionHelper.CreateGuildCommand(Discord, Id, properties, options); | |||||
| return RestGuildCommand.Create(Discord, model, this.Id); | |||||
| return RestGuildCommand.Create(Discord, model, Id); | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| /// Overwrites the application commands within this guild. | /// Overwrites the application commands within this guild. | ||||
| @@ -959,9 +959,9 @@ namespace Discord.Rest | |||||
| public async Task<IReadOnlyCollection<RestGuildCommand>> BulkOverwriteApplicationCommandsAsync(ApplicationCommandProperties[] properties, | public async Task<IReadOnlyCollection<RestGuildCommand>> BulkOverwriteApplicationCommandsAsync(ApplicationCommandProperties[] properties, | ||||
| RequestOptions options = null) | RequestOptions options = null) | ||||
| { | { | ||||
| var models = await InteractionHelper.BulkOverwriteGuildCommands(Discord, this.Id, properties, options); | |||||
| var models = await InteractionHelper.BulkOverwriteGuildCommands(Discord, Id, properties, options); | |||||
| return models.Select(x => RestGuildCommand.Create(Discord, x, this.Id)).ToImmutableArray(); | |||||
| return models.Select(x => RestGuildCommand.Create(Discord, x, Id)).ToImmutableArray(); | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -1066,7 +1066,7 @@ namespace Discord.Rest | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<CustomSticker> GetStickerAsync(ulong id, RequestOptions options = null) | public async Task<CustomSticker> GetStickerAsync(ulong id, RequestOptions options = null) | ||||
| { | { | ||||
| var model = await Discord.ApiClient.GetGuildStickerAsync(this.Id, id, options).ConfigureAwait(false); | |||||
| var model = await Discord.ApiClient.GetGuildStickerAsync(Id, id, options).ConfigureAwait(false); | |||||
| if (model == null) | if (model == null) | ||||
| return null; | return null; | ||||
| @@ -1083,7 +1083,7 @@ namespace Discord.Rest | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<IReadOnlyCollection<CustomSticker>> GetStickersAsync(RequestOptions options = null) | public async Task<IReadOnlyCollection<CustomSticker>> GetStickersAsync(RequestOptions options = null) | ||||
| { | { | ||||
| var models = await Discord.ApiClient.ListGuildStickersAsync(this.Id, options).ConfigureAwait(false); | |||||
| var models = await Discord.ApiClient.ListGuildStickersAsync(Id, options).ConfigureAwait(false); | |||||
| if (models.Length == 0) | if (models.Length == 0) | ||||
| return null; | return null; | ||||
| @@ -35,7 +35,7 @@ namespace Discord.Rest | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public DateTimeOffset CreatedAt | public DateTimeOffset CreatedAt | ||||
| => SnowflakeUtils.FromSnowflake(this.Id); | |||||
| => SnowflakeUtils.FromSnowflake(Id); | |||||
| internal RestApplicationCommand(BaseDiscordClient client, ulong id) | internal RestApplicationCommand(BaseDiscordClient client, ulong id) | ||||
| : base(client, id) | : base(client, id) | ||||
| @@ -57,13 +57,13 @@ namespace Discord.Rest | |||||
| internal virtual void Update(Model model) | internal virtual void Update(Model model) | ||||
| { | { | ||||
| this.Type = model.Type; | |||||
| this.ApplicationId = model.ApplicationId; | |||||
| this.Name = model.Name; | |||||
| this.Description = model.Description; | |||||
| this.DefaultPermission = model.DefaultPermissions.GetValueOrDefault(true); | |||||
| Type = model.Type; | |||||
| ApplicationId = model.ApplicationId; | |||||
| Name = model.Name; | |||||
| Description = model.Description; | |||||
| DefaultPermission = model.DefaultPermissions.GetValueOrDefault(true); | |||||
| this.Options = model.Options.IsSpecified | |||||
| Options = model.Options.IsSpecified | |||||
| ? model.Options.Value.Select(x => RestApplicationCommandOption.Create(x)).ToImmutableArray() | ? model.Options.Value.Select(x => RestApplicationCommandOption.Create(x)).ToImmutableArray() | ||||
| : null; | : null; | ||||
| } | } | ||||
| @@ -20,8 +20,8 @@ namespace Discord.Rest | |||||
| internal RestApplicationCommandChoice(Model model) | internal RestApplicationCommandChoice(Model model) | ||||
| { | { | ||||
| this.Name = model.Name; | |||||
| this.Value = model.Value; | |||||
| Name = model.Name; | |||||
| Value = model.Value; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -50,21 +50,21 @@ namespace Discord.Rest | |||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| this.Type = model.Type; | |||||
| this.Name = model.Name; | |||||
| this.Description = model.Description; | |||||
| Type = model.Type; | |||||
| Name = model.Name; | |||||
| Description = model.Description; | |||||
| if (model.Default.IsSpecified) | if (model.Default.IsSpecified) | ||||
| this.Default = model.Default.Value; | |||||
| Default = model.Default.Value; | |||||
| if (model.Required.IsSpecified) | if (model.Required.IsSpecified) | ||||
| this.Required = model.Required.Value; | |||||
| Required = model.Required.Value; | |||||
| this.Options = model.Options.IsSpecified | |||||
| Options = model.Options.IsSpecified | |||||
| ? model.Options.Value.Select(x => Create(x)).ToImmutableArray() | ? model.Options.Value.Select(x => Create(x)).ToImmutableArray() | ||||
| : null; | : null; | ||||
| this.Choices = model.Choices.IsSpecified | |||||
| Choices = model.Choices.IsSpecified | |||||
| ? model.Choices.Value.Select(x => new RestApplicationCommandChoice(x)).ToImmutableArray() | ? model.Choices.Value.Select(x => new RestApplicationCommandChoice(x)).ToImmutableArray() | ||||
| : null; | : null; | ||||
| } | } | ||||
| @@ -40,7 +40,7 @@ namespace Discord.Rest | |||||
| public override async Task ModifyAsync<TArg>(Action<TArg> func, RequestOptions options = null) | public override async Task ModifyAsync<TArg>(Action<TArg> func, RequestOptions options = null) | ||||
| { | { | ||||
| var cmd = await InteractionHelper.ModifyGlobalCommand<TArg>(Discord, this, func, options).ConfigureAwait(false); | var cmd = await InteractionHelper.ModifyGlobalCommand<TArg>(Discord, this, func, options).ConfigureAwait(false); | ||||
| this.Update(cmd); | |||||
| Update(cmd); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -20,7 +20,7 @@ namespace Discord.Rest | |||||
| internal RestGuildCommand(BaseDiscordClient client, ulong id, ulong guildId) | internal RestGuildCommand(BaseDiscordClient client, ulong id, ulong guildId) | ||||
| : base(client, id) | : base(client, id) | ||||
| { | { | ||||
| this.GuildId = guildId; | |||||
| GuildId = guildId; | |||||
| } | } | ||||
| internal static RestGuildCommand Create(BaseDiscordClient client, Model model, ulong guildId) | internal static RestGuildCommand Create(BaseDiscordClient client, Model model, ulong guildId) | ||||
| @@ -45,7 +45,7 @@ namespace Discord.Rest | |||||
| public override async Task ModifyAsync<TArg>(Action<TArg> func, RequestOptions options = null) | public override async Task ModifyAsync<TArg>(Action<TArg> func, RequestOptions options = null) | ||||
| { | { | ||||
| var model = await InteractionHelper.ModifyGuildCommand<TArg>(Discord, this, GuildId, func, options).ConfigureAwait(false); | var model = await InteractionHelper.ModifyGuildCommand<TArg>(Discord, this, GuildId, func, options).ConfigureAwait(false); | ||||
| this.Update(model); | |||||
| Update(model); | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -57,7 +57,7 @@ namespace Discord.Rest | |||||
| /// <see cref="GuildApplicationCommandPermission"/> object defining the permissions of the current slash command. | /// <see cref="GuildApplicationCommandPermission"/> object defining the permissions of the current slash command. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<GuildApplicationCommandPermission> GetCommandPermission(RequestOptions options = null) | public Task<GuildApplicationCommandPermission> GetCommandPermission(RequestOptions options = null) | ||||
| => InteractionHelper.GetGuildCommandPermissionAsync(Discord, this.GuildId, this.Id, options); | |||||
| => InteractionHelper.GetGuildCommandPermissionAsync(Discord, GuildId, Id, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Modifies the current command permissions for this guild command. | /// Modifies the current command permissions for this guild command. | ||||
| @@ -69,7 +69,7 @@ namespace Discord.Rest | |||||
| /// <see cref="GuildApplicationCommandPermission"/> object containing the modified permissions. | /// <see cref="GuildApplicationCommandPermission"/> object containing the modified permissions. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<GuildApplicationCommandPermission> ModifyCommandPermissions(ApplicationCommandPermission[] permissions, RequestOptions options = null) | public Task<GuildApplicationCommandPermission> ModifyCommandPermissions(ApplicationCommandPermission[] permissions, RequestOptions options = null) | ||||
| => InteractionHelper.ModifyGuildCommandPermissionsAsync(Discord, this.GuildId, this.Id, permissions, options); | |||||
| => InteractionHelper.ModifyGuildCommandPermissionsAsync(Discord, GuildId, Id, permissions, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the guild that this slash command resides in. | /// Gets the guild that this slash command resides in. | ||||
| @@ -81,6 +81,6 @@ namespace Discord.Rest | |||||
| /// <see cref="RestGuild"/>. | /// <see cref="RestGuild"/>. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<RestGuild> GetGuild(bool withCounts = false, RequestOptions options = null) | public Task<RestGuild> GetGuild(bool withCounts = false, RequestOptions options = null) | ||||
| => ClientHelper.GetGuildAsync(this.Discord, this.GuildId, withCounts, options); | |||||
| => ClientHelper.GetGuildAsync(Discord, GuildId, withCounts, options); | |||||
| } | } | ||||
| } | } | ||||
| @@ -35,14 +35,14 @@ namespace Discord.Rest | |||||
| internal CustomSticker(BaseDiscordClient client, ulong id, RestGuild guild, ulong? authorId = null) | internal CustomSticker(BaseDiscordClient client, ulong id, RestGuild guild, ulong? authorId = null) | ||||
| : base(client, id) | : base(client, id) | ||||
| { | { | ||||
| this.AuthorId = authorId; | |||||
| this.Guild = guild; | |||||
| AuthorId = authorId; | |||||
| Guild = guild; | |||||
| } | } | ||||
| internal CustomSticker(BaseDiscordClient client, ulong id, ulong guildId, ulong? authorId = null) | internal CustomSticker(BaseDiscordClient client, ulong id, ulong guildId, ulong? authorId = null) | ||||
| : base(client, id) | : base(client, id) | ||||
| { | { | ||||
| this.AuthorId = authorId; | |||||
| this.GuildId = guildId; | |||||
| AuthorId = authorId; | |||||
| GuildId = guildId; | |||||
| } | } | ||||
| internal static CustomSticker Create(BaseDiscordClient client, Model model, RestGuild guild, ulong? authorId = null) | internal static CustomSticker Create(BaseDiscordClient client, Model model, RestGuild guild, ulong? authorId = null) | ||||
| @@ -70,7 +70,7 @@ namespace Discord.Rest | |||||
| Update(model); | Update(model); | ||||
| } | } | ||||
| private string DebuggerDisplay => this.Guild != null ? $"{Name} in {Guild.Name} ({Id})" : $"{Name} ({Id})"; | |||||
| private string DebuggerDisplay => Guild != null ? $"{Name} in {Guild.Name} ({Id})" : $"{Name} ({Id})"; | |||||
| IGuild ICustomSticker.Guild => Guild; | IGuild ICustomSticker.Guild => Guild; | ||||
| } | } | ||||
| @@ -19,7 +19,7 @@ namespace Discord.Rest | |||||
| internal RestFollowupMessage(BaseDiscordClient discord, ulong id, IUser author, string token, IMessageChannel channel) | internal RestFollowupMessage(BaseDiscordClient discord, ulong id, IUser author, string token, IMessageChannel channel) | ||||
| : base(discord, id, channel, author, MessageSource.Bot) | : base(discord, id, channel, author, MessageSource.Bot) | ||||
| { | { | ||||
| this.Token = token; | |||||
| Token = token; | |||||
| } | } | ||||
| internal static RestFollowupMessage Create(BaseDiscordClient discord, Model model, string token, IMessageChannel channel) | internal static RestFollowupMessage Create(BaseDiscordClient discord, Model model, string token, IMessageChannel channel) | ||||
| @@ -66,7 +66,7 @@ namespace Discord.Rest | |||||
| try | try | ||||
| { | { | ||||
| var model = await InteractionHelper.ModifyFollowupMessage(Discord, this, func, options).ConfigureAwait(false); | var model = await InteractionHelper.ModifyFollowupMessage(Discord, this, func, options).ConfigureAwait(false); | ||||
| this.Update(model); | |||||
| Update(model); | |||||
| } | } | ||||
| catch (Discord.Net.HttpException x) | catch (Discord.Net.HttpException x) | ||||
| { | { | ||||
| @@ -15,7 +15,7 @@ namespace Discord.Rest | |||||
| internal RestInteractionMessage(BaseDiscordClient discord, ulong id, IUser author, string token, IMessageChannel channel) | internal RestInteractionMessage(BaseDiscordClient discord, ulong id, IUser author, string token, IMessageChannel channel) | ||||
| : base(discord, id, channel, author, MessageSource.Bot) | : base(discord, id, channel, author, MessageSource.Bot) | ||||
| { | { | ||||
| this.Token = token; | |||||
| Token = token; | |||||
| } | } | ||||
| internal static RestInteractionMessage Create(BaseDiscordClient discord, Model model, string token, IMessageChannel channel) | internal static RestInteractionMessage Create(BaseDiscordClient discord, Model model, string token, IMessageChannel channel) | ||||
| @@ -61,8 +61,8 @@ namespace Discord.Rest | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| var model = await InteractionHelper.ModifyInteractionResponse(Discord, this.Token, func, options).ConfigureAwait(false); | |||||
| this.Update(model); | |||||
| var model = await InteractionHelper.ModifyInteractionResponse(Discord, Token, func, options).ConfigureAwait(false); | |||||
| Update(model); | |||||
| } | } | ||||
| catch (Discord.Net.HttpException x) | catch (Discord.Net.HttpException x) | ||||
| { | { | ||||
| @@ -28,7 +28,7 @@ namespace Discord.Rest | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public string GetStickerUrl() | public string GetStickerUrl() | ||||
| => CDN.GetStickerUrl(this.Id, this.Format); | |||||
| => CDN.GetStickerUrl(Id, Format); | |||||
| internal Sticker(BaseDiscordClient client, ulong id) | internal Sticker(BaseDiscordClient client, ulong id) | ||||
| : base(client, id) { } | : base(client, id) { } | ||||
| @@ -21,8 +21,8 @@ namespace Discord.Rest | |||||
| internal StickerItem(BaseDiscordClient client, Model model) | internal StickerItem(BaseDiscordClient client, Model model) | ||||
| : base(client, model.Id) | : base(client, model.Id) | ||||
| { | { | ||||
| this.Name = model.Name; | |||||
| this.Format = model.FormatType; | |||||
| Name = model.Name; | |||||
| Format = model.FormatType; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -34,7 +34,7 @@ namespace Discord.Rest | |||||
| public async Task<Sticker> ResolveStickerAsync() | public async Task<Sticker> ResolveStickerAsync() | ||||
| { | { | ||||
| var model = await Discord.ApiClient.GetStickerAsync(this.Id); | |||||
| var model = await Discord.ApiClient.GetStickerAsync(Id); | |||||
| if (model.GuildId.IsSpecified) | if (model.GuildId.IsSpecified) | ||||
| return CustomSticker.Create(Discord, model, model.GuildId.Value, model.User.IsSpecified ? model.User.Value.Id : null); | return CustomSticker.Create(Discord, model, model.GuildId.Value, model.User.IsSpecified ? model.User.Value.Id : null); | ||||
| @@ -31,8 +31,8 @@ namespace Discord.Rest | |||||
| internal RestThreadUser(BaseDiscordClient discord, IGuild guild, IThreadChannel channel, ulong id) | internal RestThreadUser(BaseDiscordClient discord, IGuild guild, IThreadChannel channel, ulong id) | ||||
| : base(discord, id) | : base(discord, id) | ||||
| { | { | ||||
| this.Guild = guild; | |||||
| this.Thread = channel; | |||||
| Guild = guild; | |||||
| Thread = channel; | |||||
| } | } | ||||
| internal static RestThreadUser Create(BaseDiscordClient client, IGuild guild, Model model, IThreadChannel channel) | internal static RestThreadUser Create(BaseDiscordClient client, IGuild guild, Model model, IThreadChannel channel) | ||||
| @@ -44,7 +44,7 @@ namespace Discord.Rest | |||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| this.JoinedAt = model.JoinTimestamp; | |||||
| JoinedAt = model.JoinTimestamp; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -55,6 +55,6 @@ namespace Discord.Rest | |||||
| /// <see cref="IGuildUser"/> that represents the current thread user. | /// <see cref="IGuildUser"/> that represents the current thread user. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<IGuildUser> GetGuildUser() | public Task<IGuildUser> GetGuildUser() | ||||
| => Guild.GetUserAsync(this.Id); | |||||
| => Guild.GetUserAsync(Id); | |||||
| } | } | ||||
| } | } | ||||
| @@ -164,7 +164,7 @@ namespace Discord.WebSocket | |||||
| for (int i = 0; i < _shards.Length; i++) | for (int i = 0; i < _shards.Length; i++) | ||||
| await _shards[i].LoginAsync(tokenType, token); | await _shards[i].LoginAsync(tokenType, token); | ||||
| if(this._defaultStickers.Length == 0) | |||||
| if(_defaultStickers.Length == 0) | |||||
| await DownloadDefaultStickersAsync().ConfigureAwait(false); | await DownloadDefaultStickersAsync().ConfigureAwait(false); | ||||
| } | } | ||||
| @@ -82,8 +82,8 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| if (this._shardedClient != null) | |||||
| return this._shardedClient.DefaultStickerPacks; | |||||
| if (_shardedClient != null) | |||||
| return _shardedClient.DefaultStickerPacks; | |||||
| else | else | ||||
| return _defaultStickers.ToReadOnlyCollection(); | return _defaultStickers.ToReadOnlyCollection(); | ||||
| } | } | ||||
| @@ -209,7 +209,7 @@ namespace Discord.WebSocket | |||||
| internal override async Task OnLoginAsync(TokenType tokenType, string token) | internal override async Task OnLoginAsync(TokenType tokenType, string token) | ||||
| { | { | ||||
| if(this._shardedClient == null && this._defaultStickers.Length == 0) | |||||
| if(_shardedClient == null && _defaultStickers.Length == 0) | |||||
| { | { | ||||
| var models = await ApiClient.ListNitroStickerPacksAsync().ConfigureAwait(false); | var models = await ApiClient.ListNitroStickerPacksAsync().ConfigureAwait(false); | ||||
| @@ -2085,14 +2085,14 @@ namespace Discord.WebSocket | |||||
| if (channel == null) | if (channel == null) | ||||
| { | { | ||||
| var channelModel = await this.Rest.ApiClient.GetChannelAsync(data.ChannelId.Value); | |||||
| var channelModel = await Rest.ApiClient.GetChannelAsync(data.ChannelId.Value); | |||||
| if (data.GuildId.IsSpecified) | if (data.GuildId.IsSpecified) | ||||
| channel = SocketTextChannel.Create(State.GetGuild(data.GuildId.Value), this.State, channelModel); | |||||
| channel = SocketTextChannel.Create(State.GetGuild(data.GuildId.Value), State, channelModel); | |||||
| else | else | ||||
| channel = (SocketChannel)SocketChannel.CreatePrivate(this, State, channelModel); | channel = (SocketChannel)SocketChannel.CreatePrivate(this, State, channelModel); | ||||
| this.State.AddChannel(channel); | |||||
| State.AddChannel(channel); | |||||
| } | } | ||||
| if (channel is ISocketMessageChannel textChannel) | if (channel is ISocketMessageChannel textChannel) | ||||
| @@ -2224,14 +2224,14 @@ namespace Discord.WebSocket | |||||
| if ((threadChannel = guild.ThreadChannels.FirstOrDefault(x => x.Id == data.Id)) != null) | if ((threadChannel = guild.ThreadChannels.FirstOrDefault(x => x.Id == data.Id)) != null) | ||||
| { | { | ||||
| threadChannel.Update(this.State, data); | |||||
| threadChannel.Update(State, data); | |||||
| if(data.ThreadMember.IsSpecified) | if(data.ThreadMember.IsSpecified) | ||||
| threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser); | threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| threadChannel = (SocketThreadChannel)guild.AddChannel(this.State, data); | |||||
| threadChannel = (SocketThreadChannel)guild.AddChannel(State, data); | |||||
| if (data.ThreadMember.IsSpecified) | if (data.ThreadMember.IsSpecified) | ||||
| threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser); | threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser); | ||||
| } | } | ||||
| @@ -2322,11 +2322,11 @@ namespace Discord.WebSocket | |||||
| if(entity == null) | if(entity == null) | ||||
| { | { | ||||
| entity = (SocketThreadChannel)guild.AddChannel(this.State, thread); | |||||
| entity = (SocketThreadChannel)guild.AddChannel(State, thread); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| entity.Update(this.State, thread); | |||||
| entity.Update(State, thread); | |||||
| } | } | ||||
| foreach(var member in data.Members.Where(x => x.Id.Value == entity.Id)) | foreach(var member in data.Members.Where(x => x.Id.Value == entity.Id)) | ||||
| @@ -137,13 +137,13 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| return this.maxWaitForGuildAvailable; | |||||
| return maxWaitForGuildAvailable; | |||||
| } | } | ||||
| set | set | ||||
| { | { | ||||
| Preconditions.AtLeast(value, 0, nameof(this.MaxWaitBetweenGuildAvailablesBeforeReady)); | |||||
| this.maxWaitForGuildAvailable = value; | |||||
| Preconditions.AtLeast(value, 0, nameof(MaxWaitBetweenGuildAvailablesBeforeReady)); | |||||
| maxWaitForGuildAvailable = value; | |||||
| } | } | ||||
| } | } | ||||
| @@ -37,7 +37,7 @@ namespace Discord.WebSocket | |||||
| /// Gets a collection of users who are speakers within the stage. | /// Gets a collection of users who are speakers within the stage. | ||||
| /// </summary> | /// </summary> | ||||
| public IReadOnlyCollection<SocketGuildUser> Speakers | public IReadOnlyCollection<SocketGuildUser> Speakers | ||||
| => this.Users.Where(x => !x.IsSuppressed).ToImmutableArray(); | |||||
| => Users.Where(x => !x.IsSuppressed).ToImmutableArray(); | |||||
| internal new SocketStageChannel Clone() => MemberwiseClone() as SocketStageChannel; | internal new SocketStageChannel Clone() => MemberwiseClone() as SocketStageChannel; | ||||
| @@ -62,18 +62,18 @@ namespace Discord.WebSocket | |||||
| internal void Update(StageInstance model, bool isLive = false) | internal void Update(StageInstance model, bool isLive = false) | ||||
| { | { | ||||
| this.Live = isLive; | |||||
| Live = isLive; | |||||
| if (isLive) | if (isLive) | ||||
| { | { | ||||
| this.Topic = model.Topic; | |||||
| this.PrivacyLevel = model.PrivacyLevel; | |||||
| this.DiscoverableDisabled = model.DiscoverableDisabled; | |||||
| Topic = model.Topic; | |||||
| PrivacyLevel = model.PrivacyLevel; | |||||
| DiscoverableDisabled = model.DiscoverableDisabled; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| this.Topic = null; | |||||
| this.PrivacyLevel = null; | |||||
| this.DiscoverableDisabled = null; | |||||
| Topic = null; | |||||
| PrivacyLevel = null; | |||||
| DiscoverableDisabled = null; | |||||
| } | } | ||||
| } | } | ||||
| @@ -82,14 +82,14 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var args = new API.Rest.CreateStageInstanceParams() | var args = new API.Rest.CreateStageInstanceParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| Topic = topic, | Topic = topic, | ||||
| PrivacyLevel = privacyLevel, | PrivacyLevel = privacyLevel, | ||||
| }; | }; | ||||
| var model = await Discord.ApiClient.CreateStageInstanceAsync(args, options).ConfigureAwait(false); | var model = await Discord.ApiClient.CreateStageInstanceAsync(args, options).ConfigureAwait(false); | ||||
| this.Update(model, true); | |||||
| Update(model, true); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -97,13 +97,13 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var model = await ChannelHelper.ModifyAsync(this, Discord, func, options); | var model = await ChannelHelper.ModifyAsync(this, Discord, func, options); | ||||
| this.Update(model, true); | |||||
| Update(model, true); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public async Task StopStageAsync(RequestOptions options = null) | public async Task StopStageAsync(RequestOptions options = null) | ||||
| { | { | ||||
| await Discord.ApiClient.DeleteStageInstanceAsync(this.Id, options); | |||||
| await Discord.ApiClient.DeleteStageInstanceAsync(Id, options); | |||||
| Update(null, false); | Update(null, false); | ||||
| } | } | ||||
| @@ -113,10 +113,10 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var args = new API.Rest.ModifyVoiceStateParams() | var args = new API.Rest.ModifyVoiceStateParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| RequestToSpeakTimestamp = DateTimeOffset.UtcNow | RequestToSpeakTimestamp = DateTimeOffset.UtcNow | ||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | |||||
| return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -124,10 +124,10 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var args = new API.Rest.ModifyVoiceStateParams() | var args = new API.Rest.ModifyVoiceStateParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| Suppressed = false | Suppressed = false | ||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | |||||
| return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -135,10 +135,10 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var args = new API.Rest.ModifyVoiceStateParams() | var args = new API.Rest.ModifyVoiceStateParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| Suppressed = true | Suppressed = true | ||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); | |||||
| return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -146,11 +146,11 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var args = new API.Rest.ModifyVoiceStateParams() | var args = new API.Rest.ModifyVoiceStateParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| Suppressed = false | Suppressed = false | ||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); | |||||
| return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -158,11 +158,11 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var args = new API.Rest.ModifyVoiceStateParams() | var args = new API.Rest.ModifyVoiceStateParams() | ||||
| { | { | ||||
| ChannelId = this.Id, | |||||
| ChannelId = Id, | |||||
| Suppressed = true | Suppressed = true | ||||
| }; | }; | ||||
| return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); | |||||
| return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -55,7 +55,7 @@ namespace Discord.WebSocket | |||||
| /// Gets a collection of threads within this text channel. | /// Gets a collection of threads within this text channel. | ||||
| /// </summary> | /// </summary> | ||||
| public IReadOnlyCollection<SocketThreadChannel> Threads | public IReadOnlyCollection<SocketThreadChannel> Threads | ||||
| => Guild.ThreadChannels.Where(x => x.ParentChannel.Id == this.Id).ToImmutableArray(); | |||||
| => Guild.ThreadChannels.Where(x => x.ParentChannel.Id == Id).ToImmutableArray(); | |||||
| internal SocketTextChannel(DiscordSocketClient discord, ulong id, SocketGuild guild) | internal SocketTextChannel(DiscordSocketClient discord, ulong id, SocketGuild guild) | ||||
| : base(discord, id, guild) | : base(discord, id, guild) | ||||
| @@ -41,7 +41,7 @@ namespace Discord.WebSocket | |||||
| /// <see langword="true"/> if this thread is private, otherwise <see langword="false"/> | /// <see langword="true"/> if this thread is private, otherwise <see langword="false"/> | ||||
| /// </summary> | /// </summary> | ||||
| public bool IsPrivateThread | public bool IsPrivateThread | ||||
| => this.Type == ThreadType.PrivateThread; | |||||
| => Type == ThreadType.PrivateThread; | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the parent channel this thread resides in. | /// Gets the parent channel this thread resides in. | ||||
| @@ -84,8 +84,8 @@ namespace Discord.WebSocket | |||||
| internal SocketThreadChannel(DiscordSocketClient discord, SocketGuild guild, ulong id, SocketTextChannel parent) | internal SocketThreadChannel(DiscordSocketClient discord, SocketGuild guild, ulong id, SocketTextChannel parent) | ||||
| : base(discord, id, guild) | : base(discord, id, guild) | ||||
| { | { | ||||
| this.ParentChannel = parent; | |||||
| this._members = new ConcurrentDictionary<ulong, SocketThreadUser>(); | |||||
| ParentChannel = parent; | |||||
| _members = new ConcurrentDictionary<ulong, SocketThreadUser>(); | |||||
| } | } | ||||
| internal new static SocketThreadChannel Create(SocketGuild guild, ClientState state, Model model) | internal new static SocketThreadChannel Create(SocketGuild guild, ClientState state, Model model) | ||||
| @@ -100,24 +100,24 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| base.Update(state, model); | base.Update(state, model); | ||||
| this.Type = (ThreadType)model.Type; | |||||
| this.MessageCount = model.MessageCount.GetValueOrDefault(-1); | |||||
| this.MemberCount = model.MemberCount.GetValueOrDefault(-1); | |||||
| Type = (ThreadType)model.Type; | |||||
| MessageCount = model.MessageCount.GetValueOrDefault(-1); | |||||
| MemberCount = model.MemberCount.GetValueOrDefault(-1); | |||||
| if (model.ThreadMetadata.IsSpecified) | if (model.ThreadMetadata.IsSpecified) | ||||
| { | { | ||||
| this.Archived = model.ThreadMetadata.Value.Archived; | |||||
| this.ArchiveTimestamp = model.ThreadMetadata.Value.ArchiveTimestamp; | |||||
| this.AutoArchiveDuration = (ThreadArchiveDuration)model.ThreadMetadata.Value.AutoArchiveDuration; | |||||
| this.Locked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false); | |||||
| Archived = model.ThreadMetadata.Value.Archived; | |||||
| ArchiveTimestamp = model.ThreadMetadata.Value.ArchiveTimestamp; | |||||
| AutoArchiveDuration = (ThreadArchiveDuration)model.ThreadMetadata.Value.AutoArchiveDuration; | |||||
| Locked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false); | |||||
| } | } | ||||
| if (model.OwnerId.IsSpecified) | if (model.OwnerId.IsSpecified) | ||||
| { | { | ||||
| this.Owner = GetUser(model.OwnerId.Value); | |||||
| Owner = GetUser(model.OwnerId.Value); | |||||
| } | } | ||||
| this.Joined = model.ThreadMember.IsSpecified; | |||||
| Joined = model.ThreadMember.IsSpecified; | |||||
| } | } | ||||
| internal IReadOnlyCollection<SocketThreadUser> RemoveUsers(ulong[] users) | internal IReadOnlyCollection<SocketThreadUser> RemoveUsers(ulong[] users) | ||||
| @@ -139,7 +139,7 @@ namespace Discord.WebSocket | |||||
| member.Update(model); | member.Update(model); | ||||
| else | else | ||||
| { | { | ||||
| member = SocketThreadUser.Create(this.Guild, this, model, guildMember); | |||||
| member = SocketThreadUser.Create(Guild, this, model, guildMember); | |||||
| member.GlobalUser.AddRef(); | member.GlobalUser.AddRef(); | ||||
| _members[member.Id] = member; | _members[member.Id] = member; | ||||
| } | } | ||||
| @@ -167,10 +167,10 @@ namespace Discord.WebSocket | |||||
| if (!_usersDownloaded) | if (!_usersDownloaded) | ||||
| { | { | ||||
| await DownloadUsersAsync(options); | await DownloadUsersAsync(options); | ||||
| this._usersDownloaded = true; | |||||
| _usersDownloaded = true; | |||||
| } | } | ||||
| return this.Users; | |||||
| return Users; | |||||
| } | } | ||||
| @@ -181,15 +181,15 @@ namespace Discord.WebSocket | |||||
| /// <returns>A task representing the asyncronous download operation.</returns> | /// <returns>A task representing the asyncronous download operation.</returns> | ||||
| public async Task DownloadUsersAsync(RequestOptions options = null) | public async Task DownloadUsersAsync(RequestOptions options = null) | ||||
| { | { | ||||
| var users = await Discord.ApiClient.ListThreadMembersAsync(this.Id, options); | |||||
| var users = await Discord.ApiClient.ListThreadMembersAsync(Id, options); | |||||
| lock (_downloadLock) | lock (_downloadLock) | ||||
| { | { | ||||
| foreach (var threadMember in users) | foreach (var threadMember in users) | ||||
| { | { | ||||
| var guildUser = this.Guild.GetUser(threadMember.UserId.Value); | |||||
| var guildUser = Guild.GetUser(threadMember.UserId.Value); | |||||
| this.AddOrUpdateThreadMember(threadMember, guildUser); | |||||
| AddOrUpdateThreadMember(threadMember, guildUser); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -198,11 +198,11 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public Task JoinAsync(RequestOptions options = null) | public Task JoinAsync(RequestOptions options = null) | ||||
| => Discord.ApiClient.JoinThreadAsync(this.Id, options); | |||||
| => Discord.ApiClient.JoinThreadAsync(Id, options); | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public Task LeaveAsync(RequestOptions options = null) | public Task LeaveAsync(RequestOptions options = null) | ||||
| => Discord.ApiClient.LeaveThreadAsync(this.Id, options); | |||||
| => Discord.ApiClient.LeaveThreadAsync(Id, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Adds a user to this thread. | /// Adds a user to this thread. | ||||
| @@ -213,7 +213,7 @@ namespace Discord.WebSocket | |||||
| /// A task that represents the asynchronous operation of adding a member to a thread. | /// A task that represents the asynchronous operation of adding a member to a thread. | ||||
| /// </returns> | /// </returns> | ||||
| public Task AddUserAsync(IGuildUser user, RequestOptions options = null) | public Task AddUserAsync(IGuildUser user, RequestOptions options = null) | ||||
| => Discord.ApiClient.AddThreadMemberAsync(this.Id, user.Id, options); | |||||
| => Discord.ApiClient.AddThreadMemberAsync(Id, user.Id, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Removes a user from this thread. | /// Removes a user from this thread. | ||||
| @@ -224,7 +224,7 @@ namespace Discord.WebSocket | |||||
| /// A task that represents the asynchronous operation of removing a user from this thread. | /// A task that represents the asynchronous operation of removing a user from this thread. | ||||
| /// </returns> | /// </returns> | ||||
| public Task RemoveUserAsync(IGuildUser user, RequestOptions options = null) | public Task RemoveUserAsync(IGuildUser user, RequestOptions options = null) | ||||
| => Discord.ApiClient.RemoveThreadMemberAsync(this.Id, user.Id, options); | |||||
| => Discord.ApiClient.RemoveThreadMemberAsync(Id, user.Id, options); | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -339,6 +339,6 @@ namespace Discord.WebSocket | |||||
| public override Task SyncPermissionsAsync(RequestOptions options = null) | public override Task SyncPermissionsAsync(RequestOptions options = null) | ||||
| => throw new NotImplementedException(); | => throw new NotImplementedException(); | ||||
| string IChannel.Name => this.Name; | |||||
| string IChannel.Name => Name; | |||||
| } | } | ||||
| } | } | ||||
| @@ -842,7 +842,7 @@ namespace Discord.WebSocket | |||||
| /// A task that represents the asynchronous delete operation. | /// A task that represents the asynchronous delete operation. | ||||
| /// </returns> | /// </returns> | ||||
| public Task DeleteApplicationCommandsAsync(RequestOptions options = null) | public Task DeleteApplicationCommandsAsync(RequestOptions options = null) | ||||
| => InteractionHelper.DeleteAllGuildCommandsAsync(Discord, this.Id, options); | |||||
| => InteractionHelper.DeleteAllGuildCommandsAsync(Discord, Id, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a collection of slash commands created by the current user in this guild. | /// Gets a collection of slash commands created by the current user in this guild. | ||||
| @@ -854,7 +854,7 @@ namespace Discord.WebSocket | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<IReadOnlyCollection<SocketApplicationCommand>> GetApplicationCommandsAsync(RequestOptions options = null) | public async Task<IReadOnlyCollection<SocketApplicationCommand>> GetApplicationCommandsAsync(RequestOptions options = null) | ||||
| { | { | ||||
| var commands = (await Discord.ApiClient.GetGuildApplicationCommandsAsync(this.Id, options)).Select(x => SocketApplicationCommand.Create(Discord, x, this.Id)); | |||||
| var commands = (await Discord.ApiClient.GetGuildApplicationCommandsAsync(Id, options)).Select(x => SocketApplicationCommand.Create(Discord, x, Id)); | |||||
| foreach (var command in commands) | foreach (var command in commands) | ||||
| { | { | ||||
| @@ -889,7 +889,7 @@ namespace Discord.WebSocket | |||||
| if (model == null) | if (model == null) | ||||
| return null; | return null; | ||||
| command = SocketApplicationCommand.Create(Discord, model, this.Id); | |||||
| command = SocketApplicationCommand.Create(Discord, model, Id); | |||||
| Discord.State.AddCommand(command); | Discord.State.AddCommand(command); | ||||
| @@ -906,7 +906,7 @@ namespace Discord.WebSocket | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<SocketApplicationCommand> CreateApplicationCommandAsync(ApplicationCommandProperties properties, RequestOptions options = null) | public async Task<SocketApplicationCommand> CreateApplicationCommandAsync(ApplicationCommandProperties properties, RequestOptions options = null) | ||||
| { | { | ||||
| var model = await InteractionHelper.CreateGuildCommand(Discord, this.Id, properties, options); | |||||
| var model = await InteractionHelper.CreateGuildCommand(Discord, Id, properties, options); | |||||
| var entity = Discord.State.GetOrAddCommand(model.Id, (id) => SocketApplicationCommand.Create(Discord, model)); | var entity = Discord.State.GetOrAddCommand(model.Id, (id) => SocketApplicationCommand.Create(Discord, model)); | ||||
| @@ -926,11 +926,11 @@ namespace Discord.WebSocket | |||||
| public async Task<IReadOnlyCollection<SocketApplicationCommand>> BulkOverwriteApplicationCommandAsync(ApplicationCommandProperties[] properties, | public async Task<IReadOnlyCollection<SocketApplicationCommand>> BulkOverwriteApplicationCommandAsync(ApplicationCommandProperties[] properties, | ||||
| RequestOptions options = null) | RequestOptions options = null) | ||||
| { | { | ||||
| var models = await InteractionHelper.BulkOverwriteGuildCommands(Discord, this.Id, properties, options); | |||||
| var models = await InteractionHelper.BulkOverwriteGuildCommands(Discord, Id, properties, options); | |||||
| var entities = models.Select(x => SocketApplicationCommand.Create(Discord, x)); | var entities = models.Select(x => SocketApplicationCommand.Create(Discord, x)); | ||||
| Discord.State.PurgeCommands(x => !x.IsGlobalCommand && x.Guild.Id == this.Id); | |||||
| Discord.State.PurgeCommands(x => !x.IsGlobalCommand && x.Guild.Id == Id); | |||||
| foreach(var entity in entities) | foreach(var entity in entities) | ||||
| { | { | ||||
| @@ -1016,7 +1016,7 @@ namespace Discord.WebSocket | |||||
| internal SocketRole AddOrUpdateRole(RoleModel model) | internal SocketRole AddOrUpdateRole(RoleModel model) | ||||
| { | { | ||||
| if (_roles.TryGetValue(model.Id, out SocketRole role)) | if (_roles.TryGetValue(model.Id, out SocketRole role)) | ||||
| _roles[model.Id].Update(this.Discord.State, model); | |||||
| _roles[model.Id].Update(Discord.State, model); | |||||
| else | else | ||||
| role = AddRole(model); | role = AddRole(model); | ||||
| @@ -1291,7 +1291,7 @@ namespace Discord.WebSocket | |||||
| if (mode == CacheMode.CacheOnly) | if (mode == CacheMode.CacheOnly) | ||||
| return null; | return null; | ||||
| var model = await Discord.ApiClient.GetGuildStickerAsync(this.Id, id, options).ConfigureAwait(false); | |||||
| var model = await Discord.ApiClient.GetGuildStickerAsync(Id, id, options).ConfigureAwait(false); | |||||
| if (model == null) | if (model == null) | ||||
| return null; | return null; | ||||
| @@ -1317,13 +1317,13 @@ namespace Discord.WebSocket | |||||
| public async ValueTask<IReadOnlyCollection<SocketCustomSticker>> GetStickersAsync(CacheMode mode = CacheMode.AllowDownload, | public async ValueTask<IReadOnlyCollection<SocketCustomSticker>> GetStickersAsync(CacheMode mode = CacheMode.AllowDownload, | ||||
| RequestOptions options = null) | RequestOptions options = null) | ||||
| { | { | ||||
| if (this.Stickers.Count > 0) | |||||
| return this.Stickers; | |||||
| if (Stickers.Count > 0) | |||||
| return Stickers; | |||||
| if (mode == CacheMode.CacheOnly) | if (mode == CacheMode.CacheOnly) | ||||
| return ImmutableArray.Create<SocketCustomSticker>(); | return ImmutableArray.Create<SocketCustomSticker>(); | ||||
| var models = await Discord.ApiClient.ListGuildStickersAsync(this.Id, options).ConfigureAwait(false); | |||||
| var models = await Discord.ApiClient.ListGuildStickersAsync(Id, options).ConfigureAwait(false); | |||||
| List<SocketCustomSticker> stickers = new(); | List<SocketCustomSticker> stickers = new(); | ||||
| @@ -25,7 +25,7 @@ namespace Discord.WebSocket | |||||
| : null; | : null; | ||||
| ulong? guildId = null; | ulong? guildId = null; | ||||
| if (this.Channel is SocketGuildChannel guildChannel) | |||||
| if (Channel is SocketGuildChannel guildChannel) | |||||
| guildId = guildChannel.Guild.Id; | guildId = guildChannel.Guild.Id; | ||||
| Data = SocketMessageCommandData.Create(client, dataModel, model.Id, guildId); | Data = SocketMessageCommandData.Create(client, dataModel, model.Id, guildId); | ||||
| @@ -25,7 +25,7 @@ namespace Discord.WebSocket | |||||
| : null; | : null; | ||||
| ulong? guildId = null; | ulong? guildId = null; | ||||
| if (this.Channel is SocketGuildChannel guildChannel) | |||||
| if (Channel is SocketGuildChannel guildChannel) | |||||
| guildId = guildChannel.Guild.Id; | guildId = guildChannel.Guild.Id; | ||||
| Data = SocketUserCommandData.Create(client, dataModel, model.Id, guildId); | Data = SocketUserCommandData.Create(client, dataModel, model.Id, guildId); | ||||
| @@ -32,7 +32,7 @@ namespace Discord.WebSocket | |||||
| (DataModel)model.Data.Value | (DataModel)model.Data.Value | ||||
| : null; | : null; | ||||
| this.Data = new SocketMessageComponentData(dataModel); | |||||
| Data = new SocketMessageComponentData(dataModel); | |||||
| } | } | ||||
| new internal static SocketMessageComponent Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel) | new internal static SocketMessageComponent Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel) | ||||
| @@ -48,10 +48,10 @@ namespace Discord.WebSocket | |||||
| if (model.Message.IsSpecified) | if (model.Message.IsSpecified) | ||||
| { | { | ||||
| if (this.Message == null) | |||||
| if (Message == null) | |||||
| { | { | ||||
| SocketUser author = null; | SocketUser author = null; | ||||
| if (this.Channel is SocketGuildChannel channel) | |||||
| if (Channel is SocketGuildChannel channel) | |||||
| { | { | ||||
| if (model.Message.Value.WebhookId.IsSpecified) | if (model.Message.Value.WebhookId.IsSpecified) | ||||
| author = SocketWebhookUser.Create(channel.Guild, Discord.State, model.Message.Value.Author.Value, model.Message.Value.WebhookId.Value); | author = SocketWebhookUser.Create(channel.Guild, Discord.State, model.Message.Value.Author.Value, model.Message.Value.WebhookId.Value); | ||||
| @@ -59,13 +59,13 @@ namespace Discord.WebSocket | |||||
| author = channel.Guild.GetUser(model.Message.Value.Author.Value.Id); | author = channel.Guild.GetUser(model.Message.Value.Author.Value.Id); | ||||
| } | } | ||||
| else if (model.Message.Value.Author.IsSpecified) | else if (model.Message.Value.Author.IsSpecified) | ||||
| author = (this.Channel as SocketChannel).GetUser(model.Message.Value.Author.Value.Id); | |||||
| author = (Channel as SocketChannel).GetUser(model.Message.Value.Author.Value.Id); | |||||
| this.Message = SocketUserMessage.Create(this.Discord, this.Discord.State, author, this.Channel, model.Message.Value); | |||||
| Message = SocketUserMessage.Create(Discord, Discord.State, author, Channel, model.Message.Value); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| this.Message.Update(this.Discord.State, model.Message.Value); | |||||
| Message.Update(Discord.State, model.Message.Value); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -131,7 +131,7 @@ namespace Discord.WebSocket | |||||
| if (ephemeral) | if (ephemeral) | ||||
| response.Data.Value.Flags = MessageFlags.Ephemeral; | response.Data.Value.Flags = MessageFlags.Ephemeral; | ||||
| await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options); | |||||
| await InteractionHelper.SendInteractionResponse(Discord, response, Id, Token, options); | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -210,7 +210,7 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| }; | }; | ||||
| await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, this.Token, options); | |||||
| await InteractionHelper.SendInteractionResponse(Discord, response, Id, Token, options); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -371,7 +371,7 @@ namespace Discord.WebSocket | |||||
| }; | }; | ||||
| return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); | |||||
| return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, Id, Token, options); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -384,7 +384,7 @@ namespace Discord.WebSocket | |||||
| }; | }; | ||||
| return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); | |||||
| return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, Id, Token, options); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -29,9 +29,9 @@ namespace Discord.WebSocket | |||||
| internal SocketMessageComponentData(Model model) | internal SocketMessageComponentData(Model model) | ||||
| { | { | ||||
| this.CustomId = model.CustomId; | |||||
| this.Type = model.ComponentType; | |||||
| this.Values = model.Values.GetValueOrDefault(); | |||||
| CustomId = model.CustomId; | |||||
| Type = model.ComponentType; | |||||
| Values = model.Values.GetValueOrDefault(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -54,7 +54,7 @@ namespace Discord.WebSocket | |||||
| /// A task that represents the asynchronous operation of responding to this interaction. | /// A task that represents the asynchronous operation of responding to this interaction. | ||||
| /// </returns> | /// </returns> | ||||
| public Task RespondAsync(IEnumerable<AutocompleteResult> result, RequestOptions options = null) | public Task RespondAsync(IEnumerable<AutocompleteResult> result, RequestOptions options = null) | ||||
| => InteractionHelper.SendAutocompleteResult(Discord, result, this.Id, this.Token, options); | |||||
| => InteractionHelper.SendAutocompleteResult(Discord, result, Id, Token, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Responds to this interaction with a set of choices. | /// Responds to this interaction with a set of choices. | ||||
| @@ -71,7 +71,7 @@ namespace Discord.WebSocket | |||||
| /// A task that represents the asynchronous operation of responding to this interaction. | /// A task that represents the asynchronous operation of responding to this interaction. | ||||
| /// </returns> | /// </returns> | ||||
| public Task RespondAsync(RequestOptions options = null, params AutocompleteResult[] result) | public Task RespondAsync(RequestOptions options = null, params AutocompleteResult[] result) | ||||
| => InteractionHelper.SendAutocompleteResult(Discord, result, this.Id, this.Token, options); | |||||
| => InteractionHelper.SendAutocompleteResult(Discord, result, Id, Token, options); | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -48,13 +48,13 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var options = model.Options.Select(x => new AutocompleteOption(x.Type, x.Name, x.Value, x.Focused)); | var options = model.Options.Select(x => new AutocompleteOption(x.Type, x.Name, x.Value, x.Focused)); | ||||
| this.Current = options.FirstOrDefault(x => x.Focused); | |||||
| this.Options = options.ToImmutableArray(); | |||||
| Current = options.FirstOrDefault(x => x.Focused); | |||||
| Options = options.ToImmutableArray(); | |||||
| this.CommandName = model.Name; | |||||
| this.CommandId = model.Id; | |||||
| this.Type = model.Type; | |||||
| this.Version = model.Version; | |||||
| CommandName = model.Name; | |||||
| CommandId = model.Id; | |||||
| Type = model.Type; | |||||
| Version = model.Version; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -25,7 +25,7 @@ namespace Discord.WebSocket | |||||
| : null; | : null; | ||||
| ulong? guildId = null; | ulong? guildId = null; | ||||
| if (this.Channel is SocketGuildChannel guildChannel) | |||||
| if (Channel is SocketGuildChannel guildChannel) | |||||
| guildId = guildChannel.Guild.Id; | guildId = guildChannel.Guild.Id; | ||||
| Data = SocketSlashCommandData.Create(client, dataModel, guildId); | Data = SocketSlashCommandData.Create(client, dataModel, guildId); | ||||
| @@ -23,7 +23,7 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| base.Update(model); | base.Update(model); | ||||
| this.Options = model.Options.IsSpecified | |||||
| Options = model.Options.IsSpecified | |||||
| ? model.Options.Value.Select(x => new SocketSlashCommandDataOption(this, x)).ToImmutableArray() | ? model.Options.Value.Select(x => new SocketSlashCommandDataOption(this, x)).ToImmutableArray() | ||||
| : null; | : null; | ||||
| } | } | ||||
| @@ -28,8 +28,8 @@ namespace Discord.WebSocket | |||||
| internal SocketSlashCommandDataOption() { } | internal SocketSlashCommandDataOption() { } | ||||
| internal SocketSlashCommandDataOption(SocketSlashCommandData data, Model model) | internal SocketSlashCommandDataOption(SocketSlashCommandData data, Model model) | ||||
| { | { | ||||
| this.Name = model.Name; | |||||
| this.Type = model.Type; | |||||
| Name = model.Name; | |||||
| Type = model.Type; | |||||
| if (model.Value.IsSpecified) | if (model.Value.IsSpecified) | ||||
| { | { | ||||
| @@ -41,23 +41,23 @@ namespace Discord.WebSocket | |||||
| case ApplicationCommandOptionType.Mentionable: | case ApplicationCommandOptionType.Mentionable: | ||||
| if (ulong.TryParse($"{model.Value.Value}", out var valueId)) | if (ulong.TryParse($"{model.Value.Value}", out var valueId)) | ||||
| { | { | ||||
| switch (this.Type) | |||||
| switch (Type) | |||||
| { | { | ||||
| case ApplicationCommandOptionType.User: | case ApplicationCommandOptionType.User: | ||||
| { | { | ||||
| var guildUser = data.ResolvableData.GuildMembers.FirstOrDefault(x => x.Key == valueId).Value; | var guildUser = data.ResolvableData.GuildMembers.FirstOrDefault(x => x.Key == valueId).Value; | ||||
| if (guildUser != null) | if (guildUser != null) | ||||
| this.Value = guildUser; | |||||
| Value = guildUser; | |||||
| else | else | ||||
| this.Value = data.ResolvableData.Users.FirstOrDefault(x => x.Key == valueId).Value; | |||||
| Value = data.ResolvableData.Users.FirstOrDefault(x => x.Key == valueId).Value; | |||||
| } | } | ||||
| break; | break; | ||||
| case ApplicationCommandOptionType.Channel: | case ApplicationCommandOptionType.Channel: | ||||
| this.Value = data.ResolvableData.Channels.FirstOrDefault(x => x.Key == valueId).Value; | |||||
| Value = data.ResolvableData.Channels.FirstOrDefault(x => x.Key == valueId).Value; | |||||
| break; | break; | ||||
| case ApplicationCommandOptionType.Role: | case ApplicationCommandOptionType.Role: | ||||
| this.Value = data.ResolvableData.Roles.FirstOrDefault(x => x.Key == valueId).Value; | |||||
| Value = data.ResolvableData.Roles.FirstOrDefault(x => x.Key == valueId).Value; | |||||
| break; | break; | ||||
| case ApplicationCommandOptionType.Mentionable: | case ApplicationCommandOptionType.Mentionable: | ||||
| { | { | ||||
| @@ -66,54 +66,54 @@ namespace Discord.WebSocket | |||||
| var guildUser = data.ResolvableData.GuildMembers.FirstOrDefault(x => x.Key == valueId).Value; | var guildUser = data.ResolvableData.GuildMembers.FirstOrDefault(x => x.Key == valueId).Value; | ||||
| if (guildUser != null) | if (guildUser != null) | ||||
| this.Value = guildUser; | |||||
| Value = guildUser; | |||||
| else | else | ||||
| this.Value = data.ResolvableData.Users.FirstOrDefault(x => x.Key == valueId).Value; | |||||
| Value = data.ResolvableData.Users.FirstOrDefault(x => x.Key == valueId).Value; | |||||
| } | } | ||||
| else if(data.ResolvableData.Roles.Any(x => x.Key == valueId)) | else if(data.ResolvableData.Roles.Any(x => x.Key == valueId)) | ||||
| { | { | ||||
| this.Value = data.ResolvableData.Roles.FirstOrDefault(x => x.Key == valueId).Value; | |||||
| Value = data.ResolvableData.Roles.FirstOrDefault(x => x.Key == valueId).Value; | |||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| default: | default: | ||||
| this.Value = model.Value.Value; | |||||
| Value = model.Value.Value; | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| case ApplicationCommandOptionType.String: | case ApplicationCommandOptionType.String: | ||||
| this.Value = model.Value.ToString(); | |||||
| Value = model.Value.ToString(); | |||||
| break; | break; | ||||
| case ApplicationCommandOptionType.Integer: | case ApplicationCommandOptionType.Integer: | ||||
| { | { | ||||
| if (model.Value.Value is long val) | if (model.Value.Value is long val) | ||||
| this.Value = val; | |||||
| Value = val; | |||||
| else if (long.TryParse(model.Value.Value.ToString(), out long res)) | else if (long.TryParse(model.Value.Value.ToString(), out long res)) | ||||
| this.Value = res; | |||||
| Value = res; | |||||
| } | } | ||||
| break; | break; | ||||
| case ApplicationCommandOptionType.Boolean: | case ApplicationCommandOptionType.Boolean: | ||||
| { | { | ||||
| if (model.Value.Value is bool val) | if (model.Value.Value is bool val) | ||||
| this.Value = val; | |||||
| Value = val; | |||||
| else if (bool.TryParse(model.Value.Value.ToString(), out bool res)) | else if (bool.TryParse(model.Value.Value.ToString(), out bool res)) | ||||
| this.Value = res; | |||||
| Value = res; | |||||
| } | } | ||||
| break; | break; | ||||
| case ApplicationCommandOptionType.Number: | case ApplicationCommandOptionType.Number: | ||||
| { | { | ||||
| if (model.Value.Value is int val) | if (model.Value.Value is int val) | ||||
| this.Value = val; | |||||
| Value = val; | |||||
| else if (double.TryParse(model.Value.Value.ToString(), out double res)) | else if (double.TryParse(model.Value.Value.ToString(), out double res)) | ||||
| this.Value = res; | |||||
| Value = res; | |||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| this.Options = model.Options.IsSpecified | |||||
| Options = model.Options.IsSpecified | |||||
| ? model.Options.Value.Select(x => new SocketSlashCommandDataOption(data, x)).ToImmutableArray() | ? model.Options.Value.Select(x => new SocketSlashCommandDataOption(data, x)).ToImmutableArray() | ||||
| : null; | : null; | ||||
| } | } | ||||
| @@ -130,7 +130,7 @@ namespace Discord.WebSocket | |||||
| #region IApplicationCommandInteractionDataOption | #region IApplicationCommandInteractionDataOption | ||||
| IReadOnlyCollection<IApplicationCommandInteractionDataOption> IApplicationCommandInteractionDataOption.Options | IReadOnlyCollection<IApplicationCommandInteractionDataOption> IApplicationCommandInteractionDataOption.Options | ||||
| => this.Options; | |||||
| => Options; | |||||
| #endregion | #endregion | ||||
| } | } | ||||
| } | } | ||||
| @@ -47,20 +47,20 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public DateTimeOffset CreatedAt | public DateTimeOffset CreatedAt | ||||
| => SnowflakeUtils.FromSnowflake(this.Id); | |||||
| => SnowflakeUtils.FromSnowflake(Id); | |||||
| /// <summary> | /// <summary> | ||||
| /// Returns the guild this command resides in, if this command is a global command then it will return <see langword="null"/> | /// Returns the guild this command resides in, if this command is a global command then it will return <see langword="null"/> | ||||
| /// </summary> | /// </summary> | ||||
| public SocketGuild Guild | public SocketGuild Guild | ||||
| => GuildId.HasValue ? Discord.GetGuild(this.GuildId.Value) : null; | |||||
| => GuildId.HasValue ? Discord.GetGuild(GuildId.Value) : null; | |||||
| private ulong? GuildId { get; set; } | private ulong? GuildId { get; set; } | ||||
| internal SocketApplicationCommand(DiscordSocketClient client, ulong id, ulong? guildId) | internal SocketApplicationCommand(DiscordSocketClient client, ulong id, ulong? guildId) | ||||
| : base(client, id) | : base(client, id) | ||||
| { | { | ||||
| this.GuildId = guildId; | |||||
| GuildId = guildId; | |||||
| } | } | ||||
| internal static SocketApplicationCommand Create(DiscordSocketClient client, GatewayModel model) | internal static SocketApplicationCommand Create(DiscordSocketClient client, GatewayModel model) | ||||
| { | { | ||||
| @@ -78,19 +78,19 @@ namespace Discord.WebSocket | |||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| this.ApplicationId = model.ApplicationId; | |||||
| this.Description = model.Description; | |||||
| this.Name = model.Name; | |||||
| this.DefaultPermission = model.DefaultPermissions.GetValueOrDefault(true); | |||||
| ApplicationId = model.ApplicationId; | |||||
| Description = model.Description; | |||||
| Name = model.Name; | |||||
| DefaultPermission = model.DefaultPermissions.GetValueOrDefault(true); | |||||
| this.Options = model.Options.IsSpecified | |||||
| Options = model.Options.IsSpecified | |||||
| ? model.Options.Value.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray() | ? model.Options.Value.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray() | ||||
| : new ImmutableArray<SocketApplicationCommandOption>(); | : new ImmutableArray<SocketApplicationCommandOption>(); | ||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public Task DeleteAsync(RequestOptions options = null) | public Task DeleteAsync(RequestOptions options = null) | ||||
| => InteractionHelper.DeleteUnknownApplicationCommand(Discord, this.GuildId, this, options); | |||||
| => InteractionHelper.DeleteUnknownApplicationCommand(Discord, GuildId, this, options); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public Task ModifyAsync(Action<ApplicationCommandProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<ApplicationCommandProperties> func, RequestOptions options = null) | ||||
| @@ -103,16 +103,16 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| Model command = null; | Model command = null; | ||||
| if (this.IsGlobalCommand) | |||||
| if (IsGlobalCommand) | |||||
| { | { | ||||
| command = await InteractionHelper.ModifyGlobalCommand<TArg>(Discord, this, func, options).ConfigureAwait(false); | command = await InteractionHelper.ModifyGlobalCommand<TArg>(Discord, this, func, options).ConfigureAwait(false); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| command = await InteractionHelper.ModifyGuildCommand<TArg>(Discord, this, this.GuildId.Value, func, options); | |||||
| command = await InteractionHelper.ModifyGuildCommand<TArg>(Discord, this, GuildId.Value, func, options); | |||||
| } | } | ||||
| this.Update(command); | |||||
| Update(command); | |||||
| } | } | ||||
| #endregion | #endregion | ||||
| @@ -27,8 +27,8 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| this.Name = model.Name; | |||||
| this.Value = model.Value; | |||||
| Name = model.Name; | |||||
| Value = model.Value; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -48,23 +48,23 @@ namespace Discord.WebSocket | |||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| this.Name = model.Name; | |||||
| this.Type = model.Type; | |||||
| this.Description = model.Description; | |||||
| Name = model.Name; | |||||
| Type = model.Type; | |||||
| Description = model.Description; | |||||
| this.Default = model.Default.IsSpecified | |||||
| Default = model.Default.IsSpecified | |||||
| ? model.Default.Value | ? model.Default.Value | ||||
| : null; | : null; | ||||
| this.Required = model.Required.IsSpecified | |||||
| Required = model.Required.IsSpecified | |||||
| ? model.Required.Value | ? model.Required.Value | ||||
| : null; | : null; | ||||
| this.Choices = model.Choices.IsSpecified | |||||
| Choices = model.Choices.IsSpecified | |||||
| ? model.Choices.Value.Select(x => SocketApplicationCommandChoice.Create(x)).ToImmutableArray() | ? model.Choices.Value.Select(x => SocketApplicationCommandChoice.Create(x)).ToImmutableArray() | ||||
| : new ImmutableArray<SocketApplicationCommandChoice>(); | : new ImmutableArray<SocketApplicationCommandChoice>(); | ||||
| this.Options = model.Options.IsSpecified | |||||
| Options = model.Options.IsSpecified | |||||
| ? model.Options.Value.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray() | ? model.Options.Value.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray() | ||||
| : new ImmutableArray<SocketApplicationCommandOption>(); | : new ImmutableArray<SocketApplicationCommandOption>(); | ||||
| } | } | ||||
| @@ -41,7 +41,7 @@ namespace Discord.WebSocket | |||||
| : null; | : null; | ||||
| ulong? guildId = null; | ulong? guildId = null; | ||||
| if (this.Channel is SocketGuildChannel guildChannel) | |||||
| if (Channel is SocketGuildChannel guildChannel) | |||||
| guildId = guildChannel.Guild.Id; | guildId = guildChannel.Guild.Id; | ||||
| Data = SocketCommandBaseData.Create(client, dataModel, model.Id, guildId); | Data = SocketCommandBaseData.Create(client, dataModel, model.Id, guildId); | ||||
| @@ -60,7 +60,7 @@ namespace Discord.WebSocket | |||||
| (DataModel)model.Data.Value | (DataModel)model.Data.Value | ||||
| : null; | : null; | ||||
| this.Data.Update(data); | |||||
| Data.Update(data); | |||||
| base.Update(model); | base.Update(model); | ||||
| } | } | ||||
| @@ -124,7 +124,7 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| }; | }; | ||||
| await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options); | |||||
| await InteractionHelper.SendInteractionResponse(Discord, response, Id, Token, options); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -285,7 +285,7 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| }; | }; | ||||
| return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); | |||||
| return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, Id, Token, options); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -25,7 +25,7 @@ namespace Discord.WebSocket | |||||
| internal SocketCommandBaseData(DiscordSocketClient client, Model model, ulong? guildId) | internal SocketCommandBaseData(DiscordSocketClient client, Model model, ulong? guildId) | ||||
| : base(client, model.Id) | : base(client, model.Id) | ||||
| { | { | ||||
| this.Type = model.Type; | |||||
| Type = model.Type; | |||||
| if (model.Resolved.IsSpecified) | if (model.Resolved.IsSpecified) | ||||
| { | { | ||||
| @@ -42,7 +42,7 @@ namespace Discord.WebSocket | |||||
| internal virtual void Update(Model model) | internal virtual void Update(Model model) | ||||
| { | { | ||||
| this.Name = model.Name; | |||||
| Name = model.Name; | |||||
| } | } | ||||
| IReadOnlyCollection<IApplicationCommandInteractionDataOption> IApplicationCommandInteractionData.Options | IReadOnlyCollection<IApplicationCommandInteractionDataOption> IApplicationCommandInteractionData.Options | ||||
| @@ -32,7 +32,7 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var socketUser = discord.GetOrCreateUser(discord.State, user.Value); | var socketUser = discord.GetOrCreateUser(discord.State, user.Value); | ||||
| this.Users.Add(ulong.Parse(user.Key), socketUser); | |||||
| Users.Add(ulong.Parse(user.Key), socketUser); | |||||
| } | } | ||||
| } | } | ||||
| @@ -56,7 +56,7 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| discord.State.AddChannel(socketChannel); | discord.State.AddChannel(socketChannel); | ||||
| this.Channels.Add(ulong.Parse(channel.Key), socketChannel); | |||||
| Channels.Add(ulong.Parse(channel.Key), socketChannel); | |||||
| } | } | ||||
| } | } | ||||
| @@ -66,7 +66,7 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| member.Value.User = resolved.Users.Value[member.Key]; | member.Value.User = resolved.Users.Value[member.Key]; | ||||
| var user = guild.AddOrUpdateUser(member.Value); | var user = guild.AddOrUpdateUser(member.Value); | ||||
| this.GuildMembers.Add(ulong.Parse(member.Key), user); | |||||
| GuildMembers.Add(ulong.Parse(member.Key), user); | |||||
| } | } | ||||
| } | } | ||||
| @@ -75,7 +75,7 @@ namespace Discord.WebSocket | |||||
| foreach (var role in resolved.Roles.Value) | foreach (var role in resolved.Roles.Value) | ||||
| { | { | ||||
| var socketRole = guild.AddOrUpdateRole(role.Value); | var socketRole = guild.AddOrUpdateRole(role.Value); | ||||
| this.Roles.Add(ulong.Parse(role.Key), socketRole); | |||||
| Roles.Add(ulong.Parse(role.Key), socketRole); | |||||
| } | } | ||||
| } | } | ||||
| @@ -105,7 +105,7 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| var message = SocketMessage.Create(discord, discord.State, author, channel, msg.Value); | var message = SocketMessage.Create(discord, discord.State, author, channel, msg.Value); | ||||
| this.Messages.Add(message.Id, message); | |||||
| Messages.Add(message.Id, message); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -45,7 +45,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public DateTimeOffset CreatedAt | public DateTimeOffset CreatedAt | ||||
| => SnowflakeUtils.FromSnowflake(this.Id); | |||||
| => SnowflakeUtils.FromSnowflake(Id); | |||||
| /// <summary> | /// <summary> | ||||
| /// <see langword="true"/> if the token is valid for replying to, otherwise <see langword="false"/>. | /// <see langword="true"/> if the token is valid for replying to, otherwise <see langword="false"/>. | ||||
| @@ -58,7 +58,7 @@ namespace Discord.WebSocket | |||||
| internal SocketInteraction(DiscordSocketClient client, ulong id, ISocketMessageChannel channel) | internal SocketInteraction(DiscordSocketClient client, ulong id, ISocketMessageChannel channel) | ||||
| : base(client, id) | : base(client, id) | ||||
| { | { | ||||
| this.Channel = channel; | |||||
| Channel = channel; | |||||
| } | } | ||||
| internal static SocketInteraction Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel) | internal static SocketInteraction Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel) | ||||
| @@ -93,24 +93,24 @@ namespace Discord.WebSocket | |||||
| internal virtual void Update(Model model) | internal virtual void Update(Model model) | ||||
| { | { | ||||
| this.Data = model.Data.IsSpecified | |||||
| Data = model.Data.IsSpecified | |||||
| ? model.Data.Value | ? model.Data.Value | ||||
| : null; | : null; | ||||
| this.GuildId = model.GuildId.ToNullable(); | |||||
| this.Token = model.Token; | |||||
| this.Version = model.Version; | |||||
| this.Type = model.Type; | |||||
| GuildId = model.GuildId.ToNullable(); | |||||
| Token = model.Token; | |||||
| Version = model.Version; | |||||
| Type = model.Type; | |||||
| if (this.User == null) | |||||
| if (User == null) | |||||
| { | { | ||||
| if (model.Member.IsSpecified && model.GuildId.IsSpecified) | if (model.Member.IsSpecified && model.GuildId.IsSpecified) | ||||
| { | { | ||||
| this.User = SocketGuildUser.Create(Discord.State.GetGuild(this.GuildId.Value), Discord.State, model.Member.Value); | |||||
| User = SocketGuildUser.Create(Discord.State.GetGuild(GuildId.Value), Discord.State, model.Member.Value); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| this.User = SocketGlobalUser.Create(this.Discord, this.Discord.State, model.User.Value); | |||||
| User = SocketGlobalUser.Create(Discord, Discord.State, model.User.Value); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -192,7 +192,7 @@ namespace Discord.WebSocket | |||||
| /// <param name="options">The request options for this async request.</param> | /// <param name="options">The request options for this async request.</param> | ||||
| /// <returns>A <see cref="RestInteractionMessage"/> that represents the initial response.</returns> | /// <returns>A <see cref="RestInteractionMessage"/> that represents the initial response.</returns> | ||||
| public Task<RestInteractionMessage> GetOriginalResponseAsync(RequestOptions options = null) | public Task<RestInteractionMessage> GetOriginalResponseAsync(RequestOptions options = null) | ||||
| => InteractionHelper.GetOriginalResponseAsync(this.Discord, this.Channel, this, options); | |||||
| => InteractionHelper.GetOriginalResponseAsync(Discord, Channel, this, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Edits original response for this interaction. | /// Edits original response for this interaction. | ||||
| @@ -202,8 +202,8 @@ namespace Discord.WebSocket | |||||
| /// <returns>A <see cref="RestInteractionMessage"/> that represents the initial response.</returns> | /// <returns>A <see cref="RestInteractionMessage"/> that represents the initial response.</returns> | ||||
| public async Task<RestInteractionMessage> ModifyOriginalResponseAsync(Action<MessageProperties> func, RequestOptions options = null) | public async Task<RestInteractionMessage> ModifyOriginalResponseAsync(Action<MessageProperties> func, RequestOptions options = null) | ||||
| { | { | ||||
| var model = await InteractionHelper.ModifyInteractionResponse(this.Discord, this.Token, func, options); | |||||
| return RestInteractionMessage.Create(this.Discord, model, this.Token, this.Channel); | |||||
| var model = await InteractionHelper.ModifyInteractionResponse(Discord, Token, func, options); | |||||
| return RestInteractionMessage.Create(Discord, model, Token, Channel); | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -219,7 +219,7 @@ namespace Discord.WebSocket | |||||
| private bool CheckToken() | private bool CheckToken() | ||||
| { | { | ||||
| // Tokens last for 15 minutes according to https://discord.com/developers/docs/interactions/slash-commands#responding-to-an-interaction | // Tokens last for 15 minutes according to https://discord.com/developers/docs/interactions/slash-commands#responding-to-an-interaction | ||||
| return (DateTime.UtcNow - this.CreatedAt.UtcDateTime).TotalMinutes <= 15d; | |||||
| return (DateTime.UtcNow - CreatedAt.UtcDateTime).TotalMinutes <= 15d; | |||||
| } | } | ||||
| #endregion | #endregion | ||||
| @@ -27,7 +27,7 @@ namespace Discord.WebSocket | |||||
| /// </note> | /// </note> | ||||
| /// </remarks> | /// </remarks> | ||||
| public SocketGuildUser Author | public SocketGuildUser Author | ||||
| => this.AuthorId.HasValue ? Guild.GetUser(this.AuthorId.Value) : null; | |||||
| => AuthorId.HasValue ? Guild.GetUser(AuthorId.Value) : null; | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets the guild the sticker was created in. | /// Gets the guild the sticker was created in. | ||||
| @@ -40,8 +40,8 @@ namespace Discord.WebSocket | |||||
| internal SocketCustomSticker(DiscordSocketClient client, ulong id, SocketGuild guild, ulong? authorId = null) | internal SocketCustomSticker(DiscordSocketClient client, ulong id, SocketGuild guild, ulong? authorId = null) | ||||
| : base(client, id) | : base(client, id) | ||||
| { | { | ||||
| this.Guild = guild; | |||||
| this.AuthorId = authorId; | |||||
| Guild = guild; | |||||
| AuthorId = authorId; | |||||
| } | } | ||||
| internal static SocketCustomSticker Create(DiscordSocketClient client, Model model, SocketGuild guild, ulong? authorId = null) | internal static SocketCustomSticker Create(DiscordSocketClient client, Model model, SocketGuild guild, ulong? authorId = null) | ||||
| @@ -57,16 +57,16 @@ namespace Discord.WebSocket | |||||
| if(!Guild.CurrentUser.GuildPermissions.Has(GuildPermission.ManageEmojisAndStickers)) | if(!Guild.CurrentUser.GuildPermissions.Has(GuildPermission.ManageEmojisAndStickers)) | ||||
| throw new InvalidOperationException($"Missing permission {nameof(GuildPermission.ManageEmojisAndStickers)}"); | throw new InvalidOperationException($"Missing permission {nameof(GuildPermission.ManageEmojisAndStickers)}"); | ||||
| var model = await GuildHelper.ModifyStickerAsync(this.Discord, this.Guild.Id, this, func, options); | |||||
| var model = await GuildHelper.ModifyStickerAsync(Discord, Guild.Id, this, func, options); | |||||
| this.Update(model); | |||||
| Update(model); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public async Task DeleteAsync(RequestOptions options = null) | public async Task DeleteAsync(RequestOptions options = null) | ||||
| { | { | ||||
| await GuildHelper.DeleteStickerAsync(Discord, this.Guild.Id, this, options); | |||||
| Guild.RemoveSticker(this.Id); | |||||
| await GuildHelper.DeleteStickerAsync(Discord, Guild.Id, this, options); | |||||
| Guild.RemoveSticker(Id); | |||||
| } | } | ||||
| internal SocketCustomSticker Clone() => MemberwiseClone() as SocketCustomSticker; | internal SocketCustomSticker Clone() => MemberwiseClone() as SocketCustomSticker; | ||||
| @@ -76,10 +76,10 @@ namespace Discord.WebSocket | |||||
| #region ICustomSticker | #region ICustomSticker | ||||
| ulong? ICustomSticker.AuthorId | ulong? ICustomSticker.AuthorId | ||||
| => this.AuthorId; | |||||
| => AuthorId; | |||||
| IGuild ICustomSticker.Guild | IGuild ICustomSticker.Guild | ||||
| => this.Guild; | |||||
| => Guild; | |||||
| #endregion | #endregion | ||||
| } | } | ||||
| } | } | ||||
| @@ -42,7 +42,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| public string GetStickerUrl() | public string GetStickerUrl() | ||||
| => CDN.GetStickerUrl(this.Id, this.Format); | |||||
| => CDN.GetStickerUrl(Id, Format); | |||||
| internal SocketSticker(DiscordSocketClient client, ulong id) | internal SocketSticker(DiscordSocketClient client, ulong id) | ||||
| : base(client, id) { } | : base(client, id) { } | ||||
| @@ -62,21 +62,21 @@ namespace Discord.WebSocket | |||||
| internal virtual void Update(Model model) | internal virtual void Update(Model model) | ||||
| { | { | ||||
| this.Name = model.Name; | |||||
| this.Description = model.Desription; | |||||
| this.PackId = model.PackId; | |||||
| this.Available = model.Available; | |||||
| this.Format = model.FormatType; | |||||
| this.Type = model.Type; | |||||
| this.SortOrder = model.SortValue; | |||||
| Name = model.Name; | |||||
| Description = model.Desription; | |||||
| PackId = model.PackId; | |||||
| Available = model.Available; | |||||
| Format = model.FormatType; | |||||
| Type = model.Type; | |||||
| SortOrder = model.SortValue; | |||||
| if (model.Tags.IsSpecified) | if (model.Tags.IsSpecified) | ||||
| { | { | ||||
| this.Tags = model.Tags.Value.Split(',').Select(x => x.Trim()).ToImmutableArray(); | |||||
| Tags = model.Tags.Value.Split(',').Select(x => x.Trim()).ToImmutableArray(); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| this.Tags = ImmutableArray<string>.Empty; | |||||
| Tags = ImmutableArray<string>.Empty; | |||||
| } | } | ||||
| } | } | ||||
| @@ -87,15 +87,15 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| if (obj is API.Sticker stickerModel) | if (obj is API.Sticker stickerModel) | ||||
| { | { | ||||
| return stickerModel.Name == this.Name && | |||||
| stickerModel.Desription == this.Description && | |||||
| stickerModel.FormatType == this.Format && | |||||
| stickerModel.Id == this.Id && | |||||
| stickerModel.PackId == this.PackId && | |||||
| stickerModel.Type == this.Type && | |||||
| stickerModel.SortValue == this.SortOrder && | |||||
| stickerModel.Available == this.Available && | |||||
| (!stickerModel.Tags.IsSpecified || stickerModel.Tags.Value == string.Join(", ", this.Tags)); | |||||
| return stickerModel.Name == Name && | |||||
| stickerModel.Desription == Description && | |||||
| stickerModel.FormatType == Format && | |||||
| stickerModel.Id == Id && | |||||
| stickerModel.PackId == PackId && | |||||
| stickerModel.Type == Type && | |||||
| stickerModel.SortValue == SortOrder && | |||||
| stickerModel.Available == Available && | |||||
| (!stickerModel.Tags.IsSpecified || stickerModel.Tags.Value == string.Join(", ", Tags)); | |||||
| } | } | ||||
| else | else | ||||
| return base.Equals(obj); | return base.Equals(obj); | ||||
| @@ -49,8 +49,8 @@ namespace Discord.WebSocket | |||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| this.Name = model.Name; | |||||
| this.Format = model.FormatType; | |||||
| Name = model.Name; | |||||
| Format = model.FormatType; | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -60,7 +60,7 @@ namespace Discord.WebSocket | |||||
| /// The sticker representing this unknown stickers Id, if none is found then <see langword="null"/>. | /// The sticker representing this unknown stickers Id, if none is found then <see langword="null"/>. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<SocketSticker> ResolveAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null) | public Task<SocketSticker> ResolveAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null) | ||||
| => Discord.GetStickerAsync(this.Id, mode, options); | |||||
| => Discord.GetStickerAsync(Id, mode, options); | |||||
| private new string DebuggerDisplay => $"{Name} ({Id})"; | private new string DebuggerDisplay => $"{Name} ({Id})"; | ||||
| } | } | ||||
| @@ -136,9 +136,9 @@ namespace Discord.WebSocket | |||||
| internal SocketThreadUser(SocketGuild guild, SocketThreadChannel thread, SocketGuildUser member) | internal SocketThreadUser(SocketGuild guild, SocketThreadChannel thread, SocketGuildUser member) | ||||
| : base(guild.Discord, member.Id) | : base(guild.Discord, member.Id) | ||||
| { | { | ||||
| this.Thread = thread; | |||||
| this.Guild = guild; | |||||
| this.GuildUser = member; | |||||
| Thread = thread; | |||||
| Guild = guild; | |||||
| GuildUser = member; | |||||
| } | } | ||||
| internal static SocketThreadUser Create(SocketGuild guild, SocketThreadChannel thread, Model model, SocketGuildUser member) | internal static SocketThreadUser Create(SocketGuild guild, SocketThreadChannel thread, Model model, SocketGuildUser member) | ||||
| @@ -150,16 +150,16 @@ namespace Discord.WebSocket | |||||
| internal void Update(Model model) | internal void Update(Model model) | ||||
| { | { | ||||
| this.ThreadJoinedAt = model.JoinTimestamp; | |||||
| ThreadJoinedAt = model.JoinTimestamp; | |||||
| if (model.Presence.IsSpecified) | if (model.Presence.IsSpecified) | ||||
| { | { | ||||
| this.GuildUser.Update(Discord.State, model.Presence.Value, true); | |||||
| GuildUser.Update(Discord.State, model.Presence.Value, true); | |||||
| } | } | ||||
| if (model.Member.IsSpecified) | if (model.Member.IsSpecified) | ||||
| { | { | ||||
| this.GuildUser.Update(Discord.State, model.Member.Value); | |||||
| GuildUser.Update(Discord.State, model.Member.Value); | |||||
| } | } | ||||
| } | } | ||||
| @@ -198,16 +198,16 @@ namespace Discord.WebSocket | |||||
| public Task RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) => GuildUser.RemoveRolesAsync(roles, options); | public Task RemoveRolesAsync(IEnumerable<IRole> roles, RequestOptions options = null) => GuildUser.RemoveRolesAsync(roles, options); | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| GuildPermissions IGuildUser.GuildPermissions => this.GuildUser.GuildPermissions; | |||||
| GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions; | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| IGuild IGuildUser.Guild => this.Guild; | |||||
| IGuild IGuildUser.Guild => Guild; | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| ulong IGuildUser.GuildId => this.Guild.Id; | |||||
| ulong IGuildUser.GuildId => Guild.Id; | |||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| IReadOnlyCollection<ulong> IGuildUser.RoleIds => this.GuildUser.Roles.Select(x => x.Id).ToImmutableArray(); | |||||
| IReadOnlyCollection<ulong> IGuildUser.RoleIds => GuildUser.Roles.Select(x => x.Id).ToImmutableArray(); | |||||
| internal override SocketGlobalUser GlobalUser => GuildUser.GlobalUser; | internal override SocketGlobalUser GlobalUser => GuildUser.GlobalUser; | ||||
| @@ -20,9 +20,9 @@ namespace TestHelper | |||||
| throw new ArgumentOutOfRangeException(nameof(column), "column must be >= -1"); | throw new ArgumentOutOfRangeException(nameof(column), "column must be >= -1"); | ||||
| } | } | ||||
| this.Path = path; | |||||
| this.Line = line; | |||||
| this.Column = column; | |||||
| Path = path; | |||||
| Line = line; | |||||
| Column = column; | |||||
| } | } | ||||
| public string Path { get; } | public string Path { get; } | ||||
| @@ -41,16 +41,16 @@ namespace TestHelper | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| if (this.locations == null) | |||||
| if (locations == null) | |||||
| { | { | ||||
| this.locations = new DiagnosticResultLocation[] { }; | |||||
| locations = new DiagnosticResultLocation[] { }; | |||||
| } | } | ||||
| return this.locations; | |||||
| return locations; | |||||
| } | } | ||||
| set | set | ||||
| { | { | ||||
| this.locations = value; | |||||
| locations = value; | |||||
| } | } | ||||
| } | } | ||||
| @@ -64,7 +64,7 @@ namespace TestHelper | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| return this.Locations.Length > 0 ? this.Locations[0].Path : ""; | |||||
| return Locations.Length > 0 ? Locations[0].Path : ""; | |||||
| } | } | ||||
| } | } | ||||
| @@ -72,7 +72,7 @@ namespace TestHelper | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| return this.Locations.Length > 0 ? this.Locations[0].Line : -1; | |||||
| return Locations.Length > 0 ? Locations[0].Line : -1; | |||||
| } | } | ||||
| } | } | ||||
| @@ -80,7 +80,7 @@ namespace TestHelper | |||||
| { | { | ||||
| get | get | ||||
| { | { | ||||
| return this.Locations.Length > 0 ? this.Locations[0].Column : -1; | |||||
| return Locations.Length > 0 ? Locations[0].Column : -1; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -19,7 +19,7 @@ namespace Discord | |||||
| public ChannelsTests(RestGuildFixture guildFixture, ITestOutputHelper output) | public ChannelsTests(RestGuildFixture guildFixture, ITestOutputHelper output) | ||||
| { | { | ||||
| guild = guildFixture.Guild; | guild = guildFixture.Guild; | ||||
| this.output = output; | |||||
| output = output; | |||||
| output.WriteLine($"RestGuildFixture using guild: {guild.Id}"); | output.WriteLine($"RestGuildFixture using guild: {guild.Id}"); | ||||
| // capture all console output | // capture all console output | ||||
| guildFixture.Client.Log += LogAsync; | guildFixture.Client.Log += LogAsync; | ||||
| @@ -18,7 +18,7 @@ namespace Discord | |||||
| { | { | ||||
| client = guildFixture.Client; | client = guildFixture.Client; | ||||
| guild = guildFixture.Guild; | guild = guildFixture.Guild; | ||||
| this.output = output; | |||||
| output = output; | |||||
| output.WriteLine($"RestGuildFixture using guild: {guild.Id}"); | output.WriteLine($"RestGuildFixture using guild: {guild.Id}"); | ||||
| guildFixture.Client.Log += LogAsync; | guildFixture.Client.Log += LogAsync; | ||||
| } | } | ||||