Browse Source

Removed-this. (#191)

pull/1923/head
Simon Hjorthøj GitHub 4 years ago
parent
commit
0136decceb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 550 additions and 543 deletions
  1. +15
    -8
      src/Discord.Net.Core/Discord.Net.Core.xml
  2. +4
    -4
      src/Discord.Net.Core/Entities/Interactions/AutocompleteOption.cs
  3. +2
    -2
      src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs
  4. +4
    -4
      src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs
  5. +4
    -4
      src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs
  6. +1
    -1
      src/Discord.Net.Core/Entities/Interactions/Message Components/ActionRowComponent.cs
  7. +7
    -7
      src/Discord.Net.Core/Entities/Interactions/Message Components/ButtonComponent.cs
  8. +75
    -75
      src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
  9. +1
    -1
      src/Discord.Net.Core/Entities/Interactions/Message Components/MessageComponent.cs
  10. +12
    -12
      src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuComponent.cs
  11. +5
    -5
      src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuOption.cs
  12. +37
    -37
      src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs
  13. +9
    -9
      src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissions.cs
  14. +4
    -4
      src/Discord.Net.Core/Entities/Permissions/GuildApplicationCommandPermissions.cs
  15. +8
    -8
      src/Discord.Net.Core/Entities/Stickers/StickerPack.cs
  16. +2
    -2
      src/Discord.Net.Rest/API/Common/ActionRowComponent.cs
  17. +15
    -15
      src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs
  18. +9
    -9
      src/Discord.Net.Rest/API/Common/ButtonComponent.cs
  19. +7
    -7
      src/Discord.Net.Rest/API/Common/SelectMenuComponent.cs
  20. +6
    -6
      src/Discord.Net.Rest/API/Common/SelectMenuOption.cs
  21. +1
    -1
      src/Discord.Net.Rest/API/Net/MultipartFile.cs
  22. +4
    -4
      src/Discord.Net.Rest/API/Rest/CreateApplicationCommandParams.cs
  23. +21
    -21
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  24. +20
    -20
      src/Discord.Net.Rest/Entities/Channels/RestStageChannel.cs
  25. +1
    -1
      src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
  26. +13
    -13
      src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs
  27. +8
    -8
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  28. +7
    -7
      src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs
  29. +2
    -2
      src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandChoice.cs
  30. +7
    -7
      src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs
  31. +1
    -1
      src/Discord.Net.Rest/Entities/Interactions/RestGlobalCommand.cs
  32. +5
    -5
      src/Discord.Net.Rest/Entities/Interactions/RestGuildCommand.cs
  33. +5
    -5
      src/Discord.Net.Rest/Entities/Messages/CustomSticker.cs
  34. +2
    -2
      src/Discord.Net.Rest/Entities/Messages/RestFollowupMessage.cs
  35. +3
    -3
      src/Discord.Net.Rest/Entities/Messages/RestInteractionMessage.cs
  36. +1
    -1
      src/Discord.Net.Rest/Entities/Messages/Sticker.cs
  37. +3
    -3
      src/Discord.Net.Rest/Entities/Messages/StickerItem.cs
  38. +4
    -4
      src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs
  39. +1
    -1
      src/Discord.Net.WebSocket/DiscordShardedClient.cs
  40. +10
    -10
      src/Discord.Net.WebSocket/DiscordSocketClient.cs
  41. +3
    -3
      src/Discord.Net.WebSocket/DiscordSocketConfig.cs
  42. +22
    -22
      src/Discord.Net.WebSocket/Entities/Channels/SocketStageChannel.cs
  43. +1
    -1
      src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs
  44. +23
    -23
      src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs
  45. +11
    -11
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
  46. +1
    -1
      src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/Message Commands/SocketMessageCommand.cs
  47. +1
    -1
      src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommand.cs
  48. +10
    -10
      src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs
  49. +3
    -3
      src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponentData.cs
  50. +2
    -2
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteraction.cs
  51. +6
    -6
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteractionData.cs
  52. +1
    -1
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs
  53. +1
    -1
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs
  54. +20
    -20
      src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs
  55. +12
    -12
      src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommand.cs
  56. +2
    -2
      src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandChoice.cs
  57. +7
    -7
      src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandOption.cs
  58. +4
    -4
      src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs
  59. +2
    -2
      src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBaseData.cs
  60. +5
    -5
      src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs
  61. +14
    -14
      src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs
  62. +9
    -9
      src/Discord.Net.WebSocket/Entities/Stickers/SocketCustomSticker.cs
  63. +19
    -19
      src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs
  64. +3
    -3
      src/Discord.Net.WebSocket/Entities/Stickers/SocketUnknownSticker.cs
  65. +10
    -10
      src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs
  66. +10
    -10
      test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs
  67. +1
    -1
      test/Discord.Net.Tests.Integration/ChannelsTests.cs
  68. +1
    -1
      test/Discord.Net.Tests.Integration/GuildTests.cs

+ 15
- 8
src/Discord.Net.Core/Discord.Net.Core.xml View File

@@ -4917,7 +4917,11 @@
Present if this option is a group or subcommand.
</summary>
</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">
<summary>
The type of this <see cref="T:Discord.IApplicationCommandOption"/>.
@@ -5318,7 +5322,7 @@
<summary>
Builds this builder into a <see cref="T:Discord.MessageComponent"/> used to send your components.
</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 name="T:Discord.ActionRowBuilder">
<summary>
@@ -6021,6 +6025,7 @@
<param name="description">The description of this option.</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="isAutocomplete">If this option is set to autocompleate.</param>
<param name="options">The options of the option to add.</param>
<param name="choices">The choices of this option.</param>
<returns>The current builder.</returns>
@@ -8262,7 +8267,7 @@
</member>
<member name="P:Discord.ReactionMetadata.IsMe">
<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>
<returns>
<c>true</c> if the user has reacted to the message; otherwise <c>false</c>.
@@ -10266,7 +10271,7 @@
<example>
<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>
<code language="cs">
<code language="cs">
if (currentUser?.GetPermissions(targetChannel)?.AttachFiles)
await targetChannel.SendFileAsync("fortnite.png");
</code>
@@ -11086,6 +11091,7 @@
</code>
</example>
<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="options">The options to be used when sending the request.</param>
<returns>
@@ -11098,6 +11104,7 @@
<summary>
Sends an inline reply that references a message.
</summary>
<param name="msg">The message that is being replyed on.</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="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.
</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>
A task that represents an asynchronous send operation for delivering the message. The task result
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="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="component">The message component to be included with this message. Used for interactions.</param>
<returns>
A task that represents an asynchronous send operation for delivering the message. The task result
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="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="component">The message component to be included with this message. Used for interactions.</param>
<returns>
A task that represents an asynchronous send operation for delivering the message. The task result
contains the sent message.
@@ -11825,12 +11836,8 @@
<summary>
Initializes a new instance of the <see cref="T:Discord.Net.ApplicationCommandException" /> class.
</summary>
<param name="request">The request that was sent prior to the exception.</param>
<param name="requestJson"></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 name="T:Discord.Net.BucketId">
<summary>


+ 4
- 4
src/Discord.Net.Core/Entities/Interactions/AutocompleteOption.cs View File

@@ -33,10 +33,10 @@ namespace Discord

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;
}
}
}

+ 2
- 2
src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs View File

@@ -83,8 +83,8 @@ namespace Discord
/// <exception cref="ArgumentException"/>
public AutocompleteResult(string name, object value)
{
this.Name = name;
this.Value = value;
Name = name;
Value = value;
}
}
}

+ 4
- 4
src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs View File

@@ -53,8 +53,8 @@ namespace Discord
{
MessageCommandProperties props = new MessageCommandProperties()
{
Name = this.Name,
DefaultPermission = this.DefaultPermission
Name = Name,
DefaultPermission = DefaultPermission
};

return props;
@@ -70,7 +70,7 @@ namespace Discord
/// </returns>
public MessageCommandBuilder WithName(string name)
{
this.Name = name;
Name = name;
return this;
}

@@ -81,7 +81,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public MessageCommandBuilder WithDefaultPermission (bool value)
{
this.DefaultPermission = value;
DefaultPermission = value;
return this;
}
}


+ 4
- 4
src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs View File

@@ -51,8 +51,8 @@ namespace Discord
{
UserCommandProperties props = new UserCommandProperties()
{
Name = this.Name,
DefaultPermission = this.DefaultPermission
Name = Name,
DefaultPermission = DefaultPermission
};

return props;
@@ -68,7 +68,7 @@ namespace Discord
/// </returns>
public UserCommandBuilder WithName(string name)
{
this.Name = name;
Name = name;
return this;
}

@@ -79,7 +79,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public UserCommandBuilder WithDefaultPermission (bool value)
{
this.DefaultPermission = value;
DefaultPermission = value;
return this;
}
}


+ 1
- 1
src/Discord.Net.Core/Entities/Interactions/Message Components/ActionRowComponent.cs View File

@@ -25,7 +25,7 @@ namespace Discord
internal ActionRowComponent() { }
internal ActionRowComponent(List<IMessageComponent> components)
{
this.Components = components;
Components = components;
}

string IMessageComponent.CustomId => null;


+ 7
- 7
src/Discord.Net.Core/Entities/Interactions/Message Components/ButtonComponent.cs View File

@@ -55,16 +55,16 @@ namespace Discord
/// A newly created button builder with the same properties as this button.
/// </returns>
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)
{
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;
}
}
}

+ 75
- 75
src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs View File

@@ -69,14 +69,14 @@ namespace Discord
switch (component)
{
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;
case ActionRowComponent actionRow:
foreach (var cmp in actionRow.Components)
AddComponent(cmp, row);
break;
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;
}
}
@@ -187,7 +187,7 @@ namespace Discord
.WithUrl(url)
.WithDisabled(disabled);

return this.WithButton(button, row);
return WithButton(button, row);
}

/// <summary>
@@ -245,8 +245,8 @@ namespace Discord
/// <returns>A <see cref="MessageComponent"/> that can be sent with <see cref="IMessageChannel.SendMessageAsync"/>.</returns>
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
return MessageComponent.Empty;
}
@@ -295,7 +295,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public ActionRowBuilder WithComponents(List<IMessageComponent> components)
{
this.Components = components;
Components = components;
return this;
}

@@ -307,10 +307,10 @@ namespace Discord
/// <returns>The current builder.</returns>
public ActionRowBuilder AddComponent(IMessageComponent component)
{
if (this.Components.Count >= MaxChildCount)
if (Components.Count >= MaxChildCount)
throw new InvalidOperationException($"Components count reached {MaxChildCount}");

this.Components.Add(component);
Components.Add(component);
return this;
}

@@ -320,7 +320,7 @@ namespace Discord
/// <returns>A <see cref="ActionRowComponent"/> that can be used within a <see cref="ComponentBuilder"/></returns>
public ActionRowComponent Build()
{
return new ActionRowComponent(this._components);
return new ActionRowComponent(_components);
}

internal bool CanTakeComponent(IMessageComponent component)
@@ -330,12 +330,12 @@ namespace Discord
case ComponentType.ActionRow:
return false;
case ComponentType.Button:
if (this.Components.Any(x => x.Type == ComponentType.SelectMenu))
if (Components.Any(x => x.Type == ComponentType.SelectMenu))
return false;
else
return this.Components.Count < 5;
return Components.Count < 5;
case ComponentType.SelectMenu:
return this.Components.Count == 0;
return Components.Count == 0;
default:
return false;
}
@@ -435,12 +435,12 @@ namespace Discord
/// <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)
{
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>
@@ -448,12 +448,12 @@ namespace Discord
/// </summary>
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>
@@ -514,7 +514,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public ButtonBuilder WithLabel(string label)
{
this.Label = label;
Label = label;
return this;
}

@@ -525,7 +525,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public ButtonBuilder WithStyle(ButtonStyle style)
{
this.Style = style;
Style = style;
return this;
}

@@ -536,7 +536,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public ButtonBuilder WithEmote(IEmote emote)
{
this.Emote = emote;
Emote = emote;
return this;
}

@@ -547,7 +547,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public ButtonBuilder WithUrl(string url)
{
this.Url = url;
Url = url;
return this;
}

@@ -559,7 +559,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public ButtonBuilder WithCustomId(string id)
{
this.CustomId = id;
CustomId = id;
return this;
}

@@ -570,7 +570,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public ButtonBuilder WithDisabled(bool disabled)
{
this.Disabled = disabled;
Disabled = disabled;
return this;
}

@@ -585,23 +585,23 @@ namespace Discord
/// <exception cref="InvalidOperationException">A non-link button must contain a custom id</exception>
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!");

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!");

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");
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");

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>
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))
.ToList();
}
@@ -757,12 +757,12 @@ namespace Discord
/// <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)
{
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>
@@ -775,7 +775,7 @@ namespace Discord
/// </returns>
public SelectMenuBuilder WithCustomId(string customId)
{
this.CustomId = customId;
CustomId = customId;
return this;
}

@@ -789,7 +789,7 @@ namespace Discord
/// </returns>
public SelectMenuBuilder WithPlaceholder(string placeholder)
{
this.Placeholder = placeholder;
Placeholder = placeholder;
return this;
}

@@ -803,7 +803,7 @@ namespace Discord
/// </returns>
public SelectMenuBuilder WithMinValues(int minValues)
{
this.MinValues = minValues;
MinValues = minValues;
return this;
}

@@ -817,7 +817,7 @@ namespace Discord
/// </returns>
public SelectMenuBuilder WithMaxValues(int maxValues)
{
this.MaxValues = maxValues;
MaxValues = maxValues;
return this;
}

@@ -831,7 +831,7 @@ namespace Discord
/// </returns>
public SelectMenuBuilder WithOptions(List<SelectMenuOptionBuilder> options)
{
this.Options = options;
Options = options;
return this;
}

@@ -845,10 +845,10 @@ namespace Discord
/// </returns>
public SelectMenuBuilder AddOption(SelectMenuOptionBuilder option)
{
if (this.Options.Count >= MaxOptionCount)
if (Options.Count >= MaxOptionCount)
throw new InvalidOperationException($"Options count reached {MaxOptionCount}.");

this.Options.Add(option);
Options.Add(option);
return this;
}

@@ -879,7 +879,7 @@ namespace Discord
/// </returns>
public SelectMenuBuilder WithDisabled(bool disabled)
{
this.Disabled = disabled;
Disabled = disabled;
return this;
}

@@ -889,9 +889,9 @@ namespace Discord
/// <returns>The newly built <see cref="SelectMenuComponent"/></returns>
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>
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>
@@ -1024,11 +1024,11 @@ namespace Discord
/// </summary>
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>
@@ -1041,7 +1041,7 @@ namespace Discord
/// </returns>
public SelectMenuOptionBuilder WithLabel(string label)
{
this.Label = label;
Label = label;
return this;
}

@@ -1055,7 +1055,7 @@ namespace Discord
/// </returns>
public SelectMenuOptionBuilder WithValue(string value)
{
this.Value = value;
Value = value;
return this;
}

@@ -1069,7 +1069,7 @@ namespace Discord
/// </returns>
public SelectMenuOptionBuilder WithDescription(string description)
{
this.Description = description;
Description = description;
return this;
}

@@ -1082,7 +1082,7 @@ namespace Discord
/// </returns>
public SelectMenuOptionBuilder WithEmote(IEmote emote)
{
this.Emote = emote;
Emote = emote;
return this;
}

@@ -1095,7 +1095,7 @@ namespace Discord
/// </returns>
public SelectMenuOptionBuilder WithDefault(bool defaultValue)
{
this.Default = defaultValue;
Default = defaultValue;
return this;
}

@@ -1105,7 +1105,7 @@ namespace Discord
/// <returns>The newly built <see cref="SelectMenuOption"/>.</returns>
public SelectMenuOption Build()
{
return new SelectMenuOption(this.Label, this.Value, this.Description, this.Emote, this.Default);
return new SelectMenuOption(Label, Value, Description, Emote, Default);
}
}
}

+ 1
- 1
src/Discord.Net.Core/Entities/Interactions/Message Components/MessageComponent.cs View File

@@ -18,7 +18,7 @@ namespace Discord

internal MessageComponent(List<ActionRowComponent> components)
{
this.Components = components;
Components = components;
}

/// <summary>


+ 12
- 12
src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuComponent.cs View File

@@ -52,21 +52,21 @@ namespace Discord
/// </returns>
public SelectMenuBuilder ToBuilder()
=> 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)
{
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;
}
}
}

+ 5
- 5
src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuOption.cs View File

@@ -38,11 +38,11 @@ namespace Discord

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;
}
}
}

+ 37
- 37
src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs View File

@@ -100,16 +100,16 @@ namespace Discord
{
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>();

this.Options.ForEach(x => options.Add(x.Build()));
Options.ForEach(x => options.Add(x.Build()));

props.Options = options;
}
@@ -127,7 +127,7 @@ namespace Discord
/// </returns>
public SlashCommandBuilder WithName(string name)
{
this.Name = name;
Name = name;
return this;
}

@@ -138,7 +138,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public SlashCommandBuilder WithDescription(string description)
{
this.Description = description;
Description = description;
return this;
}

@@ -149,7 +149,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public SlashCommandBuilder WithDefaultPermission(bool value)
{
this.DefaultPermission = value;
DefaultPermission = value;
return this;
}

@@ -186,8 +186,8 @@ namespace Discord
// make sure theres only one option with default set to true
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));
}

@@ -237,16 +237,16 @@ namespace Discord
/// <returns>The current builder.</returns>
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!");

if (option == null)
throw new ArgumentNullException(nameof(option), "Option cannot be null");

this.Options.Add(option);
Options.Add(option);
return this;
}
/// <summary>
@@ -262,13 +262,13 @@ namespace Discord
if (options.Length == 0)
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!");

this.Options.AddRange(options);
Options.AddRange(options);
return this;
}
}
@@ -365,7 +365,7 @@ namespace Discord
/// <returns>The built version of this option.</returns>
public ApplicationCommandOptionProperties Build()
{
bool isSubType = this.Type == ApplicationCommandOptionType.SubCommandGroup;
bool isSubType = Type == ApplicationCommandOptionType.SubCommandGroup;

if (isSubType && (Options == null || !Options.Any()))
throw new ArgumentException(nameof(Options), "SubCommands/SubCommandGroups must have at least one option");
@@ -375,14 +375,14 @@ namespace Discord

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
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));
}

@@ -443,10 +443,10 @@ namespace Discord
/// <returns>The current builder.</returns>
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!");

if (option == null)
@@ -527,7 +527,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public SlashCommandOptionBuilder WithName(string name)
{
this.Name = name;
Name = name;

return this;
}
@@ -539,7 +539,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public SlashCommandOptionBuilder WithDescription(string description)
{
this.Description = description;
Description = description;
return this;
}

@@ -550,7 +550,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public SlashCommandOptionBuilder WithRequired(bool value)
{
this.Required = value;
Required = value;
return this;
}

@@ -561,7 +561,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public SlashCommandOptionBuilder WithDefault(bool value)
{
this.Default = value;
Default = value;
return this;
}

@@ -572,7 +572,7 @@ namespace Discord
/// <returns>The current builder.</returns>
public SlashCommandOptionBuilder WithType(ApplicationCommandOptionType type)
{
this.Type = type;
Type = type;
return this;
}
}


+ 9
- 9
src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissions.cs View File

@@ -30,9 +30,9 @@ namespace Discord
/// <param name="allow">The value of this permission.</param>
public ApplicationCommandPermission(ulong targetId, ApplicationCommandPermissionTarget targetType, bool allow)
{
this.TargetId = targetId;
this.TargetType = targetType;
this.Permission = allow;
TargetId = targetId;
TargetType = targetType;
Permission = allow;
}

/// <summary>
@@ -42,9 +42,9 @@ namespace Discord
/// <param name="allow">The value of this permission.</param>
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>
@@ -54,9 +54,9 @@ namespace Discord
/// <param name="allow">The value of this permission.</param>
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;
}
}
}

+ 4
- 4
src/Discord.Net.Core/Entities/Permissions/GuildApplicationCommandPermissions.cs View File

@@ -34,10 +34,10 @@ namespace Discord

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;
}
}
}

+ 8
- 8
src/Discord.Net.Core/Entities/Stickers/StickerPack.cs View File

@@ -50,14 +50,14 @@ namespace Discord

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();
}
}
}

+ 2
- 2
src/Discord.Net.Rest/API/Common/ActionRowComponent.cs View File

@@ -19,8 +19,8 @@ namespace Discord.API
internal ActionRowComponent() { }
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)
{


+ 15
- 15
src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs View File

@@ -37,28 +37,28 @@ namespace Discord.API

public ApplicationCommandOption(IApplicationCommandOption cmd)
{
this.Choices = cmd.Choices.Select(x => new ApplicationCommandOptionChoice()
Choices = cmd.Choices.Select(x => new ApplicationCommandOptionChoice()
{
Name = x.Name,
Value = x.Value
}).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
: Optional<bool>.Unspecified;
this.Default = cmd.Default.HasValue
Default = cmd.Default.HasValue
? cmd.Default.Value
: 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)
{
this.Choices = option.Choices != null
Choices = option.Choices != null
? option.Choices.Select(x => new ApplicationCommandOptionChoice()
{
Name = x.Name,
@@ -66,22 +66,22 @@ namespace Discord.API
}).ToArray()
: Optional<ApplicationCommandOptionChoice[]>.Unspecified;

this.Options = option.Options != null
Options = option.Options != null
? option.Options.Select(x => new ApplicationCommandOption(x)).ToArray()
: Optional<ApplicationCommandOption[]>.Unspecified;

this.Required = option.Required.HasValue
Required = option.Required.HasValue
? option.Required.Value
: Optional<bool>.Unspecified;

this.Default = option.Default.HasValue
Default = option.Default.HasValue
? option.Default.Value
: 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;
}
}
}

+ 9
- 9
src/Discord.Net.Rest/API/Common/ButtonComponent.cs View File

@@ -34,18 +34,18 @@ namespace Discord.API

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 is Emote e)
{
this.Emote = new Emoji()
Emote = new Emoji()
{
Name = e.Name,
Animated = e.Animated,
@@ -54,7 +54,7 @@ namespace Discord.API
}
else
{
this.Emote = new Emoji()
Emote = new Emoji()
{
Name = c.Emote.Name
};
@@ -63,6 +63,6 @@ namespace Discord.API
}

[JsonIgnore]
string IMessageComponent.CustomId => this.CustomId.GetValueOrDefault();
string IMessageComponent.CustomId => CustomId.GetValueOrDefault();
}
}

+ 7
- 7
src/Discord.Net.Rest/API/Common/SelectMenuComponent.cs View File

@@ -34,13 +34,13 @@ namespace Discord.API

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;
}
}
}

+ 6
- 6
src/Discord.Net.Rest/API/Common/SelectMenuOption.cs View File

@@ -28,15 +28,15 @@ namespace Discord.API

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 is Emote e)
{
this.Emoji = new Emoji()
Emoji = new Emoji()
{
Name = e.Name,
Animated = e.Animated,
@@ -45,14 +45,14 @@ namespace Discord.API
}
else
{
this.Emoji = new Emoji()
Emoji = new Emoji()
{
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;
}
}
}

+ 1
- 1
src/Discord.Net.Rest/API/Net/MultipartFile.cs View File

@@ -12,7 +12,7 @@ namespace Discord.Net.Rest
{
Stream = stream;
Filename = filename;
this.ContentType = contentType;
ContentType = contentType;
}
}
}

+ 4
- 4
src/Discord.Net.Rest/API/Rest/CreateApplicationCommandParams.cs View File

@@ -28,10 +28,10 @@ namespace Discord.API.Rest
public CreateApplicationCommandParams() { }
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;
}
}
}

+ 21
- 21
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -1134,7 +1134,7 @@ namespace Discord.API
{
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)
@@ -1145,7 +1145,7 @@ namespace Discord.API

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; }
}
@@ -1165,38 +1165,38 @@ namespace Discord.API

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)
{
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)
{
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)
{
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)
{
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)
{
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)
@@ -1205,7 +1205,7 @@ namespace Discord.API

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)
@@ -1216,7 +1216,7 @@ namespace Discord.API

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; }
}
@@ -1238,7 +1238,7 @@ namespace Discord.API

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)
{
@@ -1246,7 +1246,7 @@ namespace Discord.API

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)
{
@@ -1254,7 +1254,7 @@ namespace Discord.API

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)
@@ -1263,7 +1263,7 @@ namespace Discord.API

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

@@ -1283,19 +1283,19 @@ namespace Discord.API

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)
{
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)
{
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)
@@ -1345,7 +1345,7 @@ namespace Discord.API

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)
@@ -1355,7 +1355,7 @@ namespace Discord.API

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)
@@ -1365,7 +1365,7 @@ namespace Discord.API

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)
@@ -1375,7 +1375,7 @@ namespace Discord.API

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



+ 20
- 20
src/Discord.Net.Rest/Entities/Channels/RestStageChannel.cs View File

@@ -39,18 +39,18 @@ namespace Discord.Rest

internal void Update(StageInstance model, bool isLive = false)
{
this.Live = isLive;
Live = 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
{
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()
{
ChannelId = this.Id,
ChannelId = Id,
PrivacyLevel = privacyLevel,
Topic = topic
};
@@ -80,7 +80,7 @@ namespace Discord.Rest
/// <inheritdoc/>
public async Task StopStageAsync(RequestOptions options = null)
{
await Discord.ApiClient.DeleteStageInstanceAsync(this.Id, options);
await Discord.ApiClient.DeleteStageInstanceAsync(Id, options);

Update(null, false);
}
@@ -90,7 +90,7 @@ namespace Discord.Rest
{
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);
}
@@ -100,10 +100,10 @@ namespace Discord.Rest
{
var args = new API.Rest.ModifyVoiceStateParams()
{
ChannelId = this.Id,
ChannelId = Id,
RequestToSpeakTimestamp = DateTimeOffset.UtcNow
};
return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options);
return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options);
}

/// <inheritdoc/>
@@ -111,10 +111,10 @@ namespace Discord.Rest
{
var args = new API.Rest.ModifyVoiceStateParams()
{
ChannelId = this.Id,
ChannelId = Id,
Suppressed = false
};
return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options);
return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options);
}

/// <inheritdoc/>
@@ -122,10 +122,10 @@ namespace Discord.Rest
{
var args = new API.Rest.ModifyVoiceStateParams()
{
ChannelId = this.Id,
ChannelId = Id,
Suppressed = true
};
return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options);
return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options);
}

/// <inheritdoc/>
@@ -133,11 +133,11 @@ namespace Discord.Rest
{
var args = new API.Rest.ModifyVoiceStateParams()
{
ChannelId = this.Id,
ChannelId = Id,
Suppressed = false
};

return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args);
return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args);
}

/// <inheritdoc/>
@@ -145,11 +145,11 @@ namespace Discord.Rest
{
var args = new API.Rest.ModifyVoiceStateParams()
{
ChannelId = this.Id,
ChannelId = Id,
Suppressed = true
};

return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args);
return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args);
}
}
}

+ 1
- 1
src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs View File

@@ -261,7 +261,7 @@ namespace Discord.Rest
ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, RequestOptions options = null)
{
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



+ 13
- 13
src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs View File

@@ -58,21 +58,21 @@ namespace Discord.Rest
{
base.Update(model);

this.Joined = model.ThreadMember.IsSpecified;
Joined = model.ThreadMember.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>
@@ -213,18 +213,18 @@ namespace Discord.Rest
/// <inheritdoc/>
public Task JoinAsync(RequestOptions options = null)
=> Discord.ApiClient.JoinThreadAsync(this.Id, options);
=> Discord.ApiClient.JoinThreadAsync(Id, options);

/// <inheritdoc/>
public Task LeaveAsync(RequestOptions options = null)
=> Discord.ApiClient.LeaveThreadAsync(this.Id, options);
=> Discord.ApiClient.LeaveThreadAsync(Id, options);

/// <inheritdoc/>
public Task AddUserAsync(IGuildUser user, RequestOptions options = null)
=> Discord.ApiClient.AddThreadMemberAsync(this.Id, user.Id, options);
=> Discord.ApiClient.AddThreadMemberAsync(Id, user.Id, options);

/// <inheritdoc/>
public Task RemoveUserAsync(IGuildUser user, RequestOptions options = null)
=> Discord.ApiClient.RemoveThreadMemberAsync(this.Id, user.Id, options);
=> Discord.ApiClient.RemoveThreadMemberAsync(Id, user.Id, options);
}
}

+ 8
- 8
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -290,7 +290,7 @@ namespace Discord.Rest
/// A task that represents the asynchronous delete operation.
/// </returns>
public Task DeleteSlashCommandsAsync(RequestOptions options = null)
=> InteractionHelper.DeleteAllGuildCommandsAsync(Discord, this.Id, options);
=> InteractionHelper.DeleteAllGuildCommandsAsync(Discord, Id, options);

/// <summary>
/// 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"/>.
/// </returns>
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>
/// Creates an application command within this guild.
/// </summary>
@@ -944,9 +944,9 @@ namespace Discord.Rest
/// </returns>
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>
/// Overwrites the application commands within this guild.
@@ -959,9 +959,9 @@ namespace Discord.Rest
public async Task<IReadOnlyCollection<RestGuildCommand>> BulkOverwriteApplicationCommandsAsync(ApplicationCommandProperties[] properties,
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>
@@ -1066,7 +1066,7 @@ namespace Discord.Rest
/// </returns>
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)
return null;
@@ -1083,7 +1083,7 @@ namespace Discord.Rest
/// </returns>
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)
return null;


+ 7
- 7
src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs View File

@@ -35,7 +35,7 @@ namespace Discord.Rest

/// <inheritdoc/>
public DateTimeOffset CreatedAt
=> SnowflakeUtils.FromSnowflake(this.Id);
=> SnowflakeUtils.FromSnowflake(Id);

internal RestApplicationCommand(BaseDiscordClient client, ulong id)
: base(client, id)
@@ -57,13 +57,13 @@ namespace Discord.Rest

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()
: null;
}


+ 2
- 2
src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandChoice.cs View File

@@ -20,8 +20,8 @@ namespace Discord.Rest

internal RestApplicationCommandChoice(Model model)
{
this.Name = model.Name;
this.Value = model.Value;
Name = model.Name;
Value = model.Value;
}
}
}

+ 7
- 7
src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs View File

@@ -50,21 +50,21 @@ namespace Discord.Rest

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)
this.Default = model.Default.Value;
Default = model.Default.Value;

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()
: null;

this.Choices = model.Choices.IsSpecified
Choices = model.Choices.IsSpecified
? model.Choices.Value.Select(x => new RestApplicationCommandChoice(x)).ToImmutableArray()
: null;
}


+ 1
- 1
src/Discord.Net.Rest/Entities/Interactions/RestGlobalCommand.cs View File

@@ -40,7 +40,7 @@ namespace Discord.Rest
public override async Task ModifyAsync<TArg>(Action<TArg> func, RequestOptions options = null)
{
var cmd = await InteractionHelper.ModifyGlobalCommand<TArg>(Discord, this, func, options).ConfigureAwait(false);
this.Update(cmd);
Update(cmd);
}
}
}

+ 5
- 5
src/Discord.Net.Rest/Entities/Interactions/RestGuildCommand.cs View File

@@ -20,7 +20,7 @@ namespace Discord.Rest
internal RestGuildCommand(BaseDiscordClient client, ulong id, ulong guildId)
: base(client, id)
{
this.GuildId = guildId;
GuildId = 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)
{
var model = await InteractionHelper.ModifyGuildCommand<TArg>(Discord, this, GuildId, func, options).ConfigureAwait(false);
this.Update(model);
Update(model);
}

/// <summary>
@@ -57,7 +57,7 @@ namespace Discord.Rest
/// <see cref="GuildApplicationCommandPermission"/> object defining the permissions of the current slash command.
/// </returns>
public Task<GuildApplicationCommandPermission> GetCommandPermission(RequestOptions options = null)
=> InteractionHelper.GetGuildCommandPermissionAsync(Discord, this.GuildId, this.Id, options);
=> InteractionHelper.GetGuildCommandPermissionAsync(Discord, GuildId, Id, options);

/// <summary>
/// Modifies the current command permissions for this guild command.
@@ -69,7 +69,7 @@ namespace Discord.Rest
/// <see cref="GuildApplicationCommandPermission"/> object containing the modified permissions.
/// </returns>
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>
/// Gets the guild that this slash command resides in.
@@ -81,6 +81,6 @@ namespace Discord.Rest
/// <see cref="RestGuild"/>.
/// </returns>
public Task<RestGuild> GetGuild(bool withCounts = false, RequestOptions options = null)
=> ClientHelper.GetGuildAsync(this.Discord, this.GuildId, withCounts, options);
=> ClientHelper.GetGuildAsync(Discord, GuildId, withCounts, options);
}
}

+ 5
- 5
src/Discord.Net.Rest/Entities/Messages/CustomSticker.cs View File

@@ -35,14 +35,14 @@ namespace Discord.Rest
internal CustomSticker(BaseDiscordClient client, ulong id, RestGuild guild, ulong? authorId = null)
: base(client, id)
{
this.AuthorId = authorId;
this.Guild = guild;
AuthorId = authorId;
Guild = guild;
}
internal CustomSticker(BaseDiscordClient client, ulong id, ulong guildId, ulong? authorId = null)
: 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)
@@ -70,7 +70,7 @@ namespace Discord.Rest
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;
}


+ 2
- 2
src/Discord.Net.Rest/Entities/Messages/RestFollowupMessage.cs View File

@@ -19,7 +19,7 @@ namespace Discord.Rest
internal RestFollowupMessage(BaseDiscordClient discord, ulong id, IUser author, string token, IMessageChannel channel)
: base(discord, id, channel, author, MessageSource.Bot)
{
this.Token = token;
Token = token;
}

internal static RestFollowupMessage Create(BaseDiscordClient discord, Model model, string token, IMessageChannel channel)
@@ -66,7 +66,7 @@ namespace Discord.Rest
try
{
var model = await InteractionHelper.ModifyFollowupMessage(Discord, this, func, options).ConfigureAwait(false);
this.Update(model);
Update(model);
}
catch (Discord.Net.HttpException x)
{


+ 3
- 3
src/Discord.Net.Rest/Entities/Messages/RestInteractionMessage.cs View File

@@ -15,7 +15,7 @@ namespace Discord.Rest
internal RestInteractionMessage(BaseDiscordClient discord, ulong id, IUser author, string token, IMessageChannel channel)
: base(discord, id, channel, author, MessageSource.Bot)
{
this.Token = token;
Token = token;
}

internal static RestInteractionMessage Create(BaseDiscordClient discord, Model model, string token, IMessageChannel channel)
@@ -61,8 +61,8 @@ namespace Discord.Rest
{
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)
{


+ 1
- 1
src/Discord.Net.Rest/Entities/Messages/Sticker.cs View File

@@ -28,7 +28,7 @@ namespace Discord.Rest

/// <inheritdoc/>
public string GetStickerUrl()
=> CDN.GetStickerUrl(this.Id, this.Format);
=> CDN.GetStickerUrl(Id, Format);

internal Sticker(BaseDiscordClient client, ulong id)
: base(client, id) { }


+ 3
- 3
src/Discord.Net.Rest/Entities/Messages/StickerItem.cs View File

@@ -21,8 +21,8 @@ namespace Discord.Rest
internal StickerItem(BaseDiscordClient client, Model model)
: base(client, model.Id)
{
this.Name = model.Name;
this.Format = model.FormatType;
Name = model.Name;
Format = model.FormatType;
}

/// <summary>
@@ -34,7 +34,7 @@ namespace Discord.Rest

public async Task<Sticker> ResolveStickerAsync()
{
var model = await Discord.ApiClient.GetStickerAsync(this.Id);
var model = await Discord.ApiClient.GetStickerAsync(Id);

if (model.GuildId.IsSpecified)
return CustomSticker.Create(Discord, model, model.GuildId.Value, model.User.IsSpecified ? model.User.Value.Id : null);


+ 4
- 4
src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs View File

@@ -31,8 +31,8 @@ namespace Discord.Rest
internal RestThreadUser(BaseDiscordClient discord, IGuild guild, IThreadChannel channel, ulong 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)
@@ -44,7 +44,7 @@ namespace Discord.Rest

internal void Update(Model model)
{
this.JoinedAt = model.JoinTimestamp;
JoinedAt = model.JoinTimestamp;
}

/// <summary>
@@ -55,6 +55,6 @@ namespace Discord.Rest
/// <see cref="IGuildUser"/> that represents the current thread user.
/// </returns>
public Task<IGuildUser> GetGuildUser()
=> Guild.GetUserAsync(this.Id);
=> Guild.GetUserAsync(Id);
}
}

+ 1
- 1
src/Discord.Net.WebSocket/DiscordShardedClient.cs View File

@@ -164,7 +164,7 @@ namespace Discord.WebSocket
for (int i = 0; i < _shards.Length; i++)
await _shards[i].LoginAsync(tokenType, token);

if(this._defaultStickers.Length == 0)
if(_defaultStickers.Length == 0)
await DownloadDefaultStickersAsync().ConfigureAwait(false);

}


+ 10
- 10
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -82,8 +82,8 @@ namespace Discord.WebSocket
{
get
{
if (this._shardedClient != null)
return this._shardedClient.DefaultStickerPacks;
if (_shardedClient != null)
return _shardedClient.DefaultStickerPacks;
else
return _defaultStickers.ToReadOnlyCollection();
}
@@ -209,7 +209,7 @@ namespace Discord.WebSocket

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);

@@ -2085,14 +2085,14 @@ namespace Discord.WebSocket

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)
channel = SocketTextChannel.Create(State.GetGuild(data.GuildId.Value), this.State, channelModel);
channel = SocketTextChannel.Create(State.GetGuild(data.GuildId.Value), State, channelModel);
else
channel = (SocketChannel)SocketChannel.CreatePrivate(this, State, channelModel);

this.State.AddChannel(channel);
State.AddChannel(channel);
}

if (channel is ISocketMessageChannel textChannel)
@@ -2224,14 +2224,14 @@ namespace Discord.WebSocket

if ((threadChannel = guild.ThreadChannels.FirstOrDefault(x => x.Id == data.Id)) != null)
{
threadChannel.Update(this.State, data);
threadChannel.Update(State, data);

if(data.ThreadMember.IsSpecified)
threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser);
}
else
{
threadChannel = (SocketThreadChannel)guild.AddChannel(this.State, data);
threadChannel = (SocketThreadChannel)guild.AddChannel(State, data);
if (data.ThreadMember.IsSpecified)
threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser);
}
@@ -2322,11 +2322,11 @@ namespace Discord.WebSocket

if(entity == null)
{
entity = (SocketThreadChannel)guild.AddChannel(this.State, thread);
entity = (SocketThreadChannel)guild.AddChannel(State, thread);
}
else
{
entity.Update(this.State, thread);
entity.Update(State, thread);
}

foreach(var member in data.Members.Where(x => x.Id.Value == entity.Id))


+ 3
- 3
src/Discord.Net.WebSocket/DiscordSocketConfig.cs View File

@@ -137,13 +137,13 @@ namespace Discord.WebSocket
{
get
{
return this.maxWaitForGuildAvailable;
return maxWaitForGuildAvailable;
}

set
{
Preconditions.AtLeast(value, 0, nameof(this.MaxWaitBetweenGuildAvailablesBeforeReady));
this.maxWaitForGuildAvailable = value;
Preconditions.AtLeast(value, 0, nameof(MaxWaitBetweenGuildAvailablesBeforeReady));
maxWaitForGuildAvailable = value;
}
}



+ 22
- 22
src/Discord.Net.WebSocket/Entities/Channels/SocketStageChannel.cs View File

@@ -37,7 +37,7 @@ namespace Discord.WebSocket
/// Gets a collection of users who are speakers within the stage.
/// </summary>
public IReadOnlyCollection<SocketGuildUser> Speakers
=> this.Users.Where(x => !x.IsSuppressed).ToImmutableArray();
=> Users.Where(x => !x.IsSuppressed).ToImmutableArray();

internal new SocketStageChannel Clone() => MemberwiseClone() as SocketStageChannel;

@@ -62,18 +62,18 @@ namespace Discord.WebSocket

internal void Update(StageInstance model, bool isLive = false)
{
this.Live = isLive;
Live = 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
{
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()
{
ChannelId = this.Id,
ChannelId = Id,
Topic = topic,
PrivacyLevel = privacyLevel,
};

var model = await Discord.ApiClient.CreateStageInstanceAsync(args, options).ConfigureAwait(false);

this.Update(model, true);
Update(model, true);
}

/// <inheritdoc/>
@@ -97,13 +97,13 @@ namespace Discord.WebSocket
{
var model = await ChannelHelper.ModifyAsync(this, Discord, func, options);

this.Update(model, true);
Update(model, true);
}

/// <inheritdoc/>
public async Task StopStageAsync(RequestOptions options = null)
{
await Discord.ApiClient.DeleteStageInstanceAsync(this.Id, options);
await Discord.ApiClient.DeleteStageInstanceAsync(Id, options);

Update(null, false);
}
@@ -113,10 +113,10 @@ namespace Discord.WebSocket
{
var args = new API.Rest.ModifyVoiceStateParams()
{
ChannelId = this.Id,
ChannelId = Id,
RequestToSpeakTimestamp = DateTimeOffset.UtcNow
};
return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options);
return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options);
}

/// <inheritdoc/>
@@ -124,10 +124,10 @@ namespace Discord.WebSocket
{
var args = new API.Rest.ModifyVoiceStateParams()
{
ChannelId = this.Id,
ChannelId = Id,
Suppressed = false
};
return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options);
return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options);
}

/// <inheritdoc/>
@@ -135,10 +135,10 @@ namespace Discord.WebSocket
{
var args = new API.Rest.ModifyVoiceStateParams()
{
ChannelId = this.Id,
ChannelId = Id,
Suppressed = true
};
return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options);
return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options);
}

/// <inheritdoc/>
@@ -146,11 +146,11 @@ namespace Discord.WebSocket
{
var args = new API.Rest.ModifyVoiceStateParams()
{
ChannelId = this.Id,
ChannelId = Id,
Suppressed = false
};

return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args);
return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args);
}

/// <inheritdoc/>
@@ -158,11 +158,11 @@ namespace Discord.WebSocket
{
var args = new API.Rest.ModifyVoiceStateParams()
{
ChannelId = this.Id,
ChannelId = Id,
Suppressed = true
};

return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args);
return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args);
}
}
}

+ 1
- 1
src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs View File

@@ -55,7 +55,7 @@ namespace Discord.WebSocket
/// Gets a collection of threads within this text channel.
/// </summary>
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)
: base(discord, id, guild)


+ 23
- 23
src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs View File

@@ -41,7 +41,7 @@ namespace Discord.WebSocket
/// <see langword="true"/> if this thread is private, otherwise <see langword="false"/>
/// </summary>
public bool IsPrivateThread
=> this.Type == ThreadType.PrivateThread;
=> Type == ThreadType.PrivateThread;

/// <summary>
/// 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)
: 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)
@@ -100,24 +100,24 @@ namespace Discord.WebSocket
{
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)
{
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)
{
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)
@@ -139,7 +139,7 @@ namespace Discord.WebSocket
member.Update(model);
else
{
member = SocketThreadUser.Create(this.Guild, this, model, guildMember);
member = SocketThreadUser.Create(Guild, this, model, guildMember);
member.GlobalUser.AddRef();
_members[member.Id] = member;
}
@@ -167,10 +167,10 @@ namespace Discord.WebSocket
if (!_usersDownloaded)
{
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>
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)
{
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/>
public Task JoinAsync(RequestOptions options = null)
=> Discord.ApiClient.JoinThreadAsync(this.Id, options);
=> Discord.ApiClient.JoinThreadAsync(Id, options);

/// <inheritdoc/>
public Task LeaveAsync(RequestOptions options = null)
=> Discord.ApiClient.LeaveThreadAsync(this.Id, options);
=> Discord.ApiClient.LeaveThreadAsync(Id, options);

/// <summary>
/// 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.
/// </returns>
public Task AddUserAsync(IGuildUser user, RequestOptions options = null)
=> Discord.ApiClient.AddThreadMemberAsync(this.Id, user.Id, options);
=> Discord.ApiClient.AddThreadMemberAsync(Id, user.Id, options);

/// <summary>
/// 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.
/// </returns>
public Task RemoveUserAsync(IGuildUser user, RequestOptions options = null)
=> Discord.ApiClient.RemoveThreadMemberAsync(this.Id, user.Id, options);
=> Discord.ApiClient.RemoveThreadMemberAsync(Id, user.Id, options);


/// <inheritdoc/>
@@ -339,6 +339,6 @@ namespace Discord.WebSocket
public override Task SyncPermissionsAsync(RequestOptions options = null)
=> throw new NotImplementedException();

string IChannel.Name => this.Name;
string IChannel.Name => Name;
}
}

+ 11
- 11
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -842,7 +842,7 @@ namespace Discord.WebSocket
/// A task that represents the asynchronous delete operation.
/// </returns>
public Task DeleteApplicationCommandsAsync(RequestOptions options = null)
=> InteractionHelper.DeleteAllGuildCommandsAsync(Discord, this.Id, options);
=> InteractionHelper.DeleteAllGuildCommandsAsync(Discord, Id, options);

/// <summary>
/// Gets a collection of slash commands created by the current user in this guild.
@@ -854,7 +854,7 @@ namespace Discord.WebSocket
/// </returns>
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)
{
@@ -889,7 +889,7 @@ namespace Discord.WebSocket
if (model == null)
return null;

command = SocketApplicationCommand.Create(Discord, model, this.Id);
command = SocketApplicationCommand.Create(Discord, model, Id);

Discord.State.AddCommand(command);

@@ -906,7 +906,7 @@ namespace Discord.WebSocket
/// </returns>
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));

@@ -926,11 +926,11 @@ namespace Discord.WebSocket
public async Task<IReadOnlyCollection<SocketApplicationCommand>> BulkOverwriteApplicationCommandAsync(ApplicationCommandProperties[] properties,
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));

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)
{
@@ -1016,7 +1016,7 @@ namespace Discord.WebSocket
internal SocketRole AddOrUpdateRole(RoleModel model)
{
if (_roles.TryGetValue(model.Id, out SocketRole role))
_roles[model.Id].Update(this.Discord.State, model);
_roles[model.Id].Update(Discord.State, model);
else
role = AddRole(model);

@@ -1291,7 +1291,7 @@ namespace Discord.WebSocket
if (mode == CacheMode.CacheOnly)
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)
return null;
@@ -1317,13 +1317,13 @@ namespace Discord.WebSocket
public async ValueTask<IReadOnlyCollection<SocketCustomSticker>> GetStickersAsync(CacheMode mode = CacheMode.AllowDownload,
RequestOptions options = null)
{
if (this.Stickers.Count > 0)
return this.Stickers;
if (Stickers.Count > 0)
return Stickers;

if (mode == CacheMode.CacheOnly)
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();



+ 1
- 1
src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/Message Commands/SocketMessageCommand.cs View File

@@ -25,7 +25,7 @@ namespace Discord.WebSocket
: null;

ulong? guildId = null;
if (this.Channel is SocketGuildChannel guildChannel)
if (Channel is SocketGuildChannel guildChannel)
guildId = guildChannel.Guild.Id;

Data = SocketMessageCommandData.Create(client, dataModel, model.Id, guildId);


+ 1
- 1
src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommand.cs View File

@@ -25,7 +25,7 @@ namespace Discord.WebSocket
: null;

ulong? guildId = null;
if (this.Channel is SocketGuildChannel guildChannel)
if (Channel is SocketGuildChannel guildChannel)
guildId = guildChannel.Guild.Id;

Data = SocketUserCommandData.Create(client, dataModel, model.Id, guildId);


+ 10
- 10
src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs View File

@@ -32,7 +32,7 @@ namespace Discord.WebSocket
(DataModel)model.Data.Value
: null;

this.Data = new SocketMessageComponentData(dataModel);
Data = new SocketMessageComponentData(dataModel);
}

new internal static SocketMessageComponent Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel)
@@ -48,10 +48,10 @@ namespace Discord.WebSocket

if (model.Message.IsSpecified)
{
if (this.Message == null)
if (Message == null)
{
SocketUser author = null;
if (this.Channel is SocketGuildChannel channel)
if (Channel is SocketGuildChannel channel)
{
if (model.Message.Value.WebhookId.IsSpecified)
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);
}
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
{
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)
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>
@@ -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/>
@@ -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/>
@@ -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);
}
}
}

+ 3
- 3
src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponentData.cs View File

@@ -29,9 +29,9 @@ namespace Discord.WebSocket

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();
}
}
}

+ 2
- 2
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteraction.cs View File

@@ -54,7 +54,7 @@ namespace Discord.WebSocket
/// A task that represents the asynchronous operation of responding to this interaction.
/// </returns>
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>
/// 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.
/// </returns>
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/>


+ 6
- 6
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteractionData.cs View File

@@ -48,13 +48,13 @@ namespace Discord.WebSocket
{
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;
}
}
}

+ 1
- 1
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs View File

@@ -25,7 +25,7 @@ namespace Discord.WebSocket
: null;

ulong? guildId = null;
if (this.Channel is SocketGuildChannel guildChannel)
if (Channel is SocketGuildChannel guildChannel)
guildId = guildChannel.Guild.Id;

Data = SocketSlashCommandData.Create(client, dataModel, guildId);


+ 1
- 1
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs View File

@@ -23,7 +23,7 @@ namespace Discord.WebSocket
{
base.Update(model);

this.Options = model.Options.IsSpecified
Options = model.Options.IsSpecified
? model.Options.Value.Select(x => new SocketSlashCommandDataOption(this, x)).ToImmutableArray()
: null;
}


+ 20
- 20
src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs View File

@@ -28,8 +28,8 @@ namespace Discord.WebSocket
internal SocketSlashCommandDataOption() { }
internal SocketSlashCommandDataOption(SocketSlashCommandData data, Model model)
{
this.Name = model.Name;
this.Type = model.Type;
Name = model.Name;
Type = model.Type;

if (model.Value.IsSpecified)
{
@@ -41,23 +41,23 @@ namespace Discord.WebSocket
case ApplicationCommandOptionType.Mentionable:
if (ulong.TryParse($"{model.Value.Value}", out var valueId))
{
switch (this.Type)
switch (Type)
{
case ApplicationCommandOptionType.User:
{
var guildUser = data.ResolvableData.GuildMembers.FirstOrDefault(x => x.Key == valueId).Value;

if (guildUser != null)
this.Value = guildUser;
Value = guildUser;
else
this.Value = data.ResolvableData.Users.FirstOrDefault(x => x.Key == valueId).Value;
Value = data.ResolvableData.Users.FirstOrDefault(x => x.Key == valueId).Value;
}
break;
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;
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;
case ApplicationCommandOptionType.Mentionable:
{
@@ -66,54 +66,54 @@ namespace Discord.WebSocket
var guildUser = data.ResolvableData.GuildMembers.FirstOrDefault(x => x.Key == valueId).Value;

if (guildUser != null)
this.Value = guildUser;
Value = guildUser;
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))
{
this.Value = data.ResolvableData.Roles.FirstOrDefault(x => x.Key == valueId).Value;
Value = data.ResolvableData.Roles.FirstOrDefault(x => x.Key == valueId).Value;
}
}
break;
default:
this.Value = model.Value.Value;
Value = model.Value.Value;
break;
}
}
break;
case ApplicationCommandOptionType.String:
this.Value = model.Value.ToString();
Value = model.Value.ToString();
break;
case ApplicationCommandOptionType.Integer:
{
if (model.Value.Value is long val)
this.Value = val;
Value = val;
else if (long.TryParse(model.Value.Value.ToString(), out long res))
this.Value = res;
Value = res;
}
break;
case ApplicationCommandOptionType.Boolean:
{
if (model.Value.Value is bool val)
this.Value = val;
Value = val;
else if (bool.TryParse(model.Value.Value.ToString(), out bool res))
this.Value = res;
Value = res;
}
break;
case ApplicationCommandOptionType.Number:
{
if (model.Value.Value is int val)
this.Value = val;
Value = val;
else if (double.TryParse(model.Value.Value.ToString(), out double res))
this.Value = res;
Value = res;
}
break;
}

}

this.Options = model.Options.IsSpecified
Options = model.Options.IsSpecified
? model.Options.Value.Select(x => new SocketSlashCommandDataOption(data, x)).ToImmutableArray()
: null;
}
@@ -130,7 +130,7 @@ namespace Discord.WebSocket

#region IApplicationCommandInteractionDataOption
IReadOnlyCollection<IApplicationCommandInteractionDataOption> IApplicationCommandInteractionDataOption.Options
=> this.Options;
=> Options;
#endregion
}
}

+ 12
- 12
src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommand.cs View File

@@ -47,20 +47,20 @@ namespace Discord.WebSocket

/// <inheritdoc/>
public DateTimeOffset CreatedAt
=> SnowflakeUtils.FromSnowflake(this.Id);
=> SnowflakeUtils.FromSnowflake(Id);

/// <summary>
/// Returns the guild this command resides in, if this command is a global command then it will return <see langword="null"/>
/// </summary>
public SocketGuild Guild
=> GuildId.HasValue ? Discord.GetGuild(this.GuildId.Value) : null;
=> GuildId.HasValue ? Discord.GetGuild(GuildId.Value) : null;

private ulong? GuildId { get; set; }

internal SocketApplicationCommand(DiscordSocketClient client, ulong id, ulong? guildId)
: base(client, id)
{
this.GuildId = guildId;
GuildId = guildId;
}
internal static SocketApplicationCommand Create(DiscordSocketClient client, GatewayModel model)
{
@@ -78,19 +78,19 @@ namespace Discord.WebSocket

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()
: new ImmutableArray<SocketApplicationCommandOption>();
}

/// <inheritdoc/>
public Task DeleteAsync(RequestOptions options = null)
=> InteractionHelper.DeleteUnknownApplicationCommand(Discord, this.GuildId, this, options);
=> InteractionHelper.DeleteUnknownApplicationCommand(Discord, GuildId, this, options);

/// <inheritdoc />
public Task ModifyAsync(Action<ApplicationCommandProperties> func, RequestOptions options = null)
@@ -103,16 +103,16 @@ namespace Discord.WebSocket
{
Model command = null;

if (this.IsGlobalCommand)
if (IsGlobalCommand)
{
command = await InteractionHelper.ModifyGlobalCommand<TArg>(Discord, this, func, options).ConfigureAwait(false);
}
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



+ 2
- 2
src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandChoice.cs View File

@@ -27,8 +27,8 @@ namespace Discord.WebSocket
}
internal void Update(Model model)
{
this.Name = model.Name;
this.Value = model.Value;
Name = model.Name;
Value = model.Value;
}
}
}

+ 7
- 7
src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandOption.cs View File

@@ -48,23 +48,23 @@ namespace Discord.WebSocket

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
: null;

this.Required = model.Required.IsSpecified
Required = model.Required.IsSpecified
? model.Required.Value
: null;

this.Choices = model.Choices.IsSpecified
Choices = model.Choices.IsSpecified
? model.Choices.Value.Select(x => SocketApplicationCommandChoice.Create(x)).ToImmutableArray()
: new ImmutableArray<SocketApplicationCommandChoice>();

this.Options = model.Options.IsSpecified
Options = model.Options.IsSpecified
? model.Options.Value.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray()
: new ImmutableArray<SocketApplicationCommandOption>();
}


+ 4
- 4
src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs View File

@@ -41,7 +41,7 @@ namespace Discord.WebSocket
: null;

ulong? guildId = null;
if (this.Channel is SocketGuildChannel guildChannel)
if (Channel is SocketGuildChannel guildChannel)
guildId = guildChannel.Guild.Id;

Data = SocketCommandBaseData.Create(client, dataModel, model.Id, guildId);
@@ -60,7 +60,7 @@ namespace Discord.WebSocket
(DataModel)model.Data.Value
: null;

this.Data.Update(data);
Data.Update(data);

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/>
@@ -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);
}
}
}

+ 2
- 2
src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBaseData.cs View File

@@ -25,7 +25,7 @@ namespace Discord.WebSocket
internal SocketCommandBaseData(DiscordSocketClient client, Model model, ulong? guildId)
: base(client, model.Id)
{
this.Type = model.Type;
Type = model.Type;

if (model.Resolved.IsSpecified)
{
@@ -42,7 +42,7 @@ namespace Discord.WebSocket

internal virtual void Update(Model model)
{
this.Name = model.Name;
Name = model.Name;
}

IReadOnlyCollection<IApplicationCommandInteractionDataOption> IApplicationCommandInteractionData.Options


+ 5
- 5
src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs View File

@@ -32,7 +32,7 @@ namespace Discord.WebSocket
{
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);
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];
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)
{
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);
this.Messages.Add(message.Id, message);
Messages.Add(message.Id, message);
}
}
}


+ 14
- 14
src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs View File

@@ -45,7 +45,7 @@ namespace Discord.WebSocket

/// <inheritdoc/>
public DateTimeOffset CreatedAt
=> SnowflakeUtils.FromSnowflake(this.Id);
=> SnowflakeUtils.FromSnowflake(Id);

/// <summary>
/// <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)
: base(client, id)
{
this.Channel = channel;
Channel = channel;
}

internal static SocketInteraction Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel)
@@ -93,24 +93,24 @@ namespace Discord.WebSocket

internal virtual void Update(Model model)
{
this.Data = model.Data.IsSpecified
Data = model.Data.IsSpecified
? model.Data.Value
: 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)
{
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
{
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>
/// <returns>A <see cref="RestInteractionMessage"/> that represents the initial response.</returns>
public Task<RestInteractionMessage> GetOriginalResponseAsync(RequestOptions options = null)
=> InteractionHelper.GetOriginalResponseAsync(this.Discord, this.Channel, this, options);
=> InteractionHelper.GetOriginalResponseAsync(Discord, Channel, this, options);

/// <summary>
/// Edits original response for this interaction.
@@ -202,8 +202,8 @@ namespace Discord.WebSocket
/// <returns>A <see cref="RestInteractionMessage"/> that represents the initial response.</returns>
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>
@@ -219,7 +219,7 @@ namespace Discord.WebSocket
private bool CheckToken()
{
// 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



+ 9
- 9
src/Discord.Net.WebSocket/Entities/Stickers/SocketCustomSticker.cs View File

@@ -27,7 +27,7 @@ namespace Discord.WebSocket
/// </note>
/// </remarks>
public SocketGuildUser Author
=> this.AuthorId.HasValue ? Guild.GetUser(this.AuthorId.Value) : null;
=> AuthorId.HasValue ? Guild.GetUser(AuthorId.Value) : null;

/// <summary>
/// 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)
: 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)
@@ -57,16 +57,16 @@ namespace Discord.WebSocket
if(!Guild.CurrentUser.GuildPermissions.Has(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/>
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;
@@ -76,10 +76,10 @@ namespace Discord.WebSocket

#region ICustomSticker
ulong? ICustomSticker.AuthorId
=> this.AuthorId;
=> AuthorId;

IGuild ICustomSticker.Guild
=> this.Guild;
=> Guild;
#endregion
}
}

+ 19
- 19
src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs View File

@@ -42,7 +42,7 @@ namespace Discord.WebSocket

/// <inheritdoc/>
public string GetStickerUrl()
=> CDN.GetStickerUrl(this.Id, this.Format);
=> CDN.GetStickerUrl(Id, Format);

internal SocketSticker(DiscordSocketClient client, ulong id)
: base(client, id) { }
@@ -62,21 +62,21 @@ namespace Discord.WebSocket

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)
{
this.Tags = model.Tags.Value.Split(',').Select(x => x.Trim()).ToImmutableArray();
Tags = model.Tags.Value.Split(',').Select(x => x.Trim()).ToImmutableArray();
}
else
{
this.Tags = ImmutableArray<string>.Empty;
Tags = ImmutableArray<string>.Empty;
}
}

@@ -87,15 +87,15 @@ namespace Discord.WebSocket
{
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
return base.Equals(obj);


+ 3
- 3
src/Discord.Net.WebSocket/Entities/Stickers/SocketUnknownSticker.cs View File

@@ -49,8 +49,8 @@ namespace Discord.WebSocket

internal void Update(Model model)
{
this.Name = model.Name;
this.Format = model.FormatType;
Name = model.Name;
Format = model.FormatType;
}

/// <summary>
@@ -60,7 +60,7 @@ namespace Discord.WebSocket
/// The sticker representing this unknown stickers Id, if none is found then <see langword="null"/>.
/// </returns>
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})";
}


+ 10
- 10
src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs View File

@@ -136,9 +136,9 @@ namespace Discord.WebSocket
internal SocketThreadUser(SocketGuild guild, SocketThreadChannel thread, SocketGuildUser member)
: 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)
@@ -150,16 +150,16 @@ namespace Discord.WebSocket

internal void Update(Model model)
{
this.ThreadJoinedAt = model.JoinTimestamp;
ThreadJoinedAt = model.JoinTimestamp;

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)
{
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);

/// <inheritdoc/>
GuildPermissions IGuildUser.GuildPermissions => this.GuildUser.GuildPermissions;
GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions;

/// <inheritdoc/>
IGuild IGuildUser.Guild => this.Guild;
IGuild IGuildUser.Guild => Guild;

/// <inheritdoc/>
ulong IGuildUser.GuildId => this.Guild.Id;
ulong IGuildUser.GuildId => Guild.Id;

/// <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;



+ 10
- 10
test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs View File

@@ -20,9 +20,9 @@ namespace TestHelper
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; }
@@ -41,16 +41,16 @@ namespace TestHelper
{
get
{
if (this.locations == null)
if (locations == null)
{
this.locations = new DiagnosticResultLocation[] { };
locations = new DiagnosticResultLocation[] { };
}
return this.locations;
return locations;
}

set
{
this.locations = value;
locations = value;
}
}

@@ -64,7 +64,7 @@ namespace TestHelper
{
get
{
return this.Locations.Length > 0 ? this.Locations[0].Path : "";
return Locations.Length > 0 ? Locations[0].Path : "";
}
}

@@ -72,7 +72,7 @@ namespace TestHelper
{
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
{
return this.Locations.Length > 0 ? this.Locations[0].Column : -1;
return Locations.Length > 0 ? Locations[0].Column : -1;
}
}
}

+ 1
- 1
test/Discord.Net.Tests.Integration/ChannelsTests.cs View File

@@ -19,7 +19,7 @@ namespace Discord
public ChannelsTests(RestGuildFixture guildFixture, ITestOutputHelper output)
{
guild = guildFixture.Guild;
this.output = output;
output = output;
output.WriteLine($"RestGuildFixture using guild: {guild.Id}");
// capture all console output
guildFixture.Client.Log += LogAsync;


+ 1
- 1
test/Discord.Net.Tests.Integration/GuildTests.cs View File

@@ -18,7 +18,7 @@ namespace Discord
{
client = guildFixture.Client;
guild = guildFixture.Guild;
this.output = output;
output = output;
output.WriteLine($"RestGuildFixture using guild: {guild.Id}");
guildFixture.Client.Log += LogAsync;
}


Loading…
Cancel
Save