Browse Source

[Feature] Add missing property & new stuff (#2521)

* add active developer badge support

* add `OwnerId` to threads

* add default forum layout support

* oops, forgot to update modifyasync

* add missing application flags

* Add `50155` error code
tags/3.9.0
Misha133 GitHub 2 years ago
parent
commit
82b772ac03
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 95 additions and 17 deletions
  1. +1
    -0
      src/Discord.Net.Core/DiscordErrorCode.cs
  2. +26
    -15
      src/Discord.Net.Core/Entities/ApplicationFlags.cs
  3. +5
    -0
      src/Discord.Net.Core/Entities/Channels/ForumChannelProperties.cs
  4. +22
    -0
      src/Discord.Net.Core/Entities/Channels/ForumLayout.cs
  5. +6
    -1
      src/Discord.Net.Core/Entities/Channels/IForumChannel.cs
  6. +5
    -0
      src/Discord.Net.Core/Entities/Channels/IThreadChannel.cs
  7. +5
    -0
      src/Discord.Net.Core/Entities/Users/UserProperties.cs
  8. +3
    -0
      src/Discord.Net.Rest/API/Common/Channel.cs
  9. +3
    -0
      src/Discord.Net.Rest/API/Rest/ModifyForumChannelParams.cs
  10. +2
    -1
      src/Discord.Net.Rest/Entities/Channels/ForumHelper.cs
  11. +4
    -0
      src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs
  12. +5
    -0
      src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs
  13. +5
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketForumChannel.cs
  14. +3
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs

+ 1
- 0
src/Discord.Net.Core/DiscordErrorCode.cs View File

@@ -177,6 +177,7 @@ namespace Discord
OwnershipCannotBeTransferredToABotUser = 50132, OwnershipCannotBeTransferredToABotUser = 50132,
FailedToResizeAssetBelowTheMaximumSize = 50138, FailedToResizeAssetBelowTheMaximumSize = 50138,
UploadedFileNotFound = 50146, UploadedFileNotFound = 50146,
FeatureInProcessOfRollingOut = 50155,
MissingPermissionToSendThisSticker = 50600, MissingPermissionToSendThisSticker = 50600,
#endregion #endregion




+ 26
- 15
src/Discord.Net.Core/Entities/ApplicationFlags.cs View File

@@ -4,20 +4,31 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;


namespace Discord
namespace Discord;

/// <summary>
/// Represents public flags for an application.
/// </summary>
public enum ApplicationFlags
{ {
/// <summary>
/// Represents public flags for an application.
/// </summary>
public enum ApplicationFlags
{
GatewayPresence = 1 << 12,
GatewayPresenceLimited = 1 << 13,
GatewayGuildMembers = 1 << 14,
GatewayGuildMembersLimited = 1 << 15,
VerificationPendingGuildLimit = 1 << 16,
Embedded = 1 << 17,
GatewayMessageContent = 1 << 18,
GatewayMessageContentLimited = 1 << 19
}
GatewayPresence = 1 << 12,

GatewayPresenceLimited = 1 << 13,

GatewayGuildMembers = 1 << 14,

GatewayGuildMembersLimited = 1 << 15,

VerificationPendingGuildLimit = 1 << 16,

Embedded = 1 << 17,

GatewayMessageContent = 1 << 18,

GatewayMessageContentLimited = 1 << 19,

ApplicationCommandBadge = 1 << 23,

ActiveApplication = 1 << 24
} }


+ 5
- 0
src/Discord.Net.Core/Entities/Channels/ForumChannelProperties.cs View File

@@ -57,4 +57,9 @@ public class ForumChannelProperties : TextChannelProperties
/// Gets or sets the rule used to order posts in forum channels. /// Gets or sets the rule used to order posts in forum channels.
/// </summary> /// </summary>
public Optional<ForumSortOrder> DefaultSortOrder { get; set; } public Optional<ForumSortOrder> DefaultSortOrder { get; set; }

/// <summary>
/// Gets or sets the rule used to display posts in a forum channel.
/// </summary>
public Optional<ForumLayout> DefaultLayout { get; set; }
} }

+ 22
- 0
src/Discord.Net.Core/Entities/Channels/ForumLayout.cs View File

@@ -0,0 +1,22 @@
namespace Discord;

/// <summary>
/// Represents the layout type used to display posts in a forum channel.
/// </summary>
public enum ForumLayout
{
/// <summary>
/// A preferred forum layout hasn't been set by a server admin
/// </summary>
Default = 0,

/// <summary>
/// List View: display forum posts in a text-focused list
/// </summary>
List = 1,

/// <summary>
/// Gallery View: display forum posts in a media-focused gallery
/// </summary>
Grid = 2
}

+ 6
- 1
src/Discord.Net.Core/Entities/Channels/IForumChannel.cs View File

@@ -63,13 +63,18 @@ namespace Discord
IEmote DefaultReactionEmoji { get; } IEmote DefaultReactionEmoji { get; }


/// <summary> /// <summary>
/// Gets or sets the rule used to order posts in forum channels.
/// Gets the rule used to order posts in forum channels.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Defaults to null, which indicates a preferred sort order hasn't been set /// Defaults to null, which indicates a preferred sort order hasn't been set
/// </remarks> /// </remarks>
ForumSortOrder? DefaultSortOrder { get; } ForumSortOrder? DefaultSortOrder { get; }


/// <summary>
/// Gets the rule used to display posts in a forum channel.
/// </summary>
ForumLayout DefaultLayout { get; }

/// <summary> /// <summary>
/// Modifies this forum channel. /// Modifies this forum channel.
/// </summary> /// </summary>


+ 5
- 0
src/Discord.Net.Core/Entities/Channels/IThreadChannel.cs View File

@@ -74,6 +74,11 @@ namespace Discord
/// </remarks> /// </remarks>
new DateTimeOffset CreatedAt { get; } new DateTimeOffset CreatedAt { get; }


/// <summary>
/// Gets the id of the creator of the thread.
/// </summary>
ulong OwnerId { get; }

/// <summary> /// <summary>
/// Joins the current thread. /// Joins the current thread.
/// </summary> /// </summary>


+ 5
- 0
src/Discord.Net.Core/Entities/Users/UserProperties.cs View File

@@ -69,5 +69,10 @@ namespace Discord
/// Flag given to bots that use only outgoing webhooks, exclusively. /// Flag given to bots that use only outgoing webhooks, exclusively.
/// </summary> /// </summary>
BotHTTPInteractions = 1 << 19, BotHTTPInteractions = 1 << 19,

/// <summary>
/// Flag given to users that are active developers.
/// </summary>
ActiveDeveloper = 1 << 22
} }
} }

+ 3
- 0
src/Discord.Net.Rest/API/Common/Channel.cs View File

@@ -89,5 +89,8 @@ namespace Discord.API
[JsonProperty("default_reaction_emoji")] [JsonProperty("default_reaction_emoji")]
public Optional<ForumReactionEmoji> DefaultReactionEmoji { get; set; } public Optional<ForumReactionEmoji> DefaultReactionEmoji { get; set; }


[JsonProperty("default_forum_layout")]
public Optional<ForumLayout> DefaultForumLayout { get; set; }

} }
} }

+ 3
- 0
src/Discord.Net.Rest/API/Rest/ModifyForumChannelParams.cs View File

@@ -20,4 +20,7 @@ internal class ModifyForumChannelParams : ModifyTextChannelParams


[JsonProperty("default_sort_order")] [JsonProperty("default_sort_order")]
public Optional<ForumSortOrder> DefaultSortOrder { get; set; } public Optional<ForumSortOrder> DefaultSortOrder { get; set; }

[JsonProperty("default_forum_layout")]
public Optional<ForumLayout> DefaultLayout { get; set; }
} }

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

@@ -56,7 +56,8 @@ internal static class ForumHelper
emoji.Name : Optional<string>.Unspecified emoji.Name : Optional<string>.Unspecified
} }
: Optional<ModifyForumReactionEmojiParams>.Unspecified, : Optional<ModifyForumReactionEmojiParams>.Unspecified,
DefaultSortOrder = args.DefaultSortOrder
DefaultSortOrder = args.DefaultSortOrder,
DefaultLayout = args.DefaultLayout,
}; };
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
} }


+ 4
- 0
src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs View File

@@ -41,6 +41,9 @@ namespace Discord.Rest
/// <inheritdoc/> /// <inheritdoc/>
public ForumSortOrder? DefaultSortOrder { get; private set; } public ForumSortOrder? DefaultSortOrder { get; private set; }


/// <inheritdoc />
public ForumLayout DefaultLayout { get; private set; }

/// <inheritdoc/> /// <inheritdoc/>
public string Mention => MentionUtils.MentionChannel(Id); public string Mention => MentionUtils.MentionChannel(Id);


@@ -87,6 +90,7 @@ namespace Discord.Rest
} }


CategoryId = model.CategoryId.GetValueOrDefault(); CategoryId = model.CategoryId.GetValueOrDefault();
DefaultLayout= model.DefaultForumLayout.GetValueOrDefault();
} }


/// <inheritdoc/> /// <inheritdoc/>


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

@@ -40,6 +40,9 @@ namespace Discord.Rest
/// <inheritdoc/> /// <inheritdoc/>
public IReadOnlyCollection<ulong> AppliedTags { get; private set; } public IReadOnlyCollection<ulong> AppliedTags { get; private set; }


/// <inheritdoc/>
public ulong OwnerId { get; private set; }

/// <inheritdoc cref="IThreadChannel.CreatedAt"/> /// <inheritdoc cref="IThreadChannel.CreatedAt"/>
public override DateTimeOffset CreatedAt { get; } public override DateTimeOffset CreatedAt { get; }


@@ -76,6 +79,8 @@ namespace Discord.Rest
IsLocked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false); IsLocked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false);
} }


OwnerId = model.OwnerId.GetValueOrDefault(0);

MemberCount = model.MemberCount.GetValueOrDefault(0); MemberCount = model.MemberCount.GetValueOrDefault(0);
MessageCount = model.MessageCount.GetValueOrDefault(0); MessageCount = model.MessageCount.GetValueOrDefault(0);
Type = (ThreadType)model.Type; Type = (ThreadType)model.Type;


+ 5
- 0
src/Discord.Net.WebSocket/Entities/Channels/SocketForumChannel.cs View File

@@ -45,6 +45,9 @@ namespace Discord.WebSocket
/// <inheritdoc/> /// <inheritdoc/>
public ForumSortOrder? DefaultSortOrder { get; private set; } public ForumSortOrder? DefaultSortOrder { get; private set; }


/// <inheritdoc />
public ForumLayout DefaultLayout { get; private set; }

/// <summary> /// <summary>
/// Gets the parent (category) of this channel in the guild's channel list. /// Gets the parent (category) of this channel in the guild's channel list.
/// </summary> /// </summary>
@@ -93,6 +96,8 @@ namespace Discord.WebSocket
} }


CategoryId = model.CategoryId.GetValueOrDefault(); CategoryId = model.CategoryId.GetValueOrDefault();

DefaultLayout = model.DefaultForumLayout.GetValueOrDefault();
} }


/// <inheritdoc /> /// <inheritdoc />


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

@@ -95,6 +95,9 @@ namespace Discord.WebSocket
/// <inheritdoc cref="IThreadChannel.CreatedAt"/> /// <inheritdoc cref="IThreadChannel.CreatedAt"/>
public override DateTimeOffset CreatedAt { get; } public override DateTimeOffset CreatedAt { get; }


/// <inheritdoc cref="IThreadChannel.OwnerId"/>
ulong IThreadChannel.OwnerId => _ownerId;

/// <summary> /// <summary>
/// Gets a collection of cached users within this thread. /// Gets a collection of cached users within this thread.
/// </summary> /// </summary>


Loading…
Cancel
Save