[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
This commit is contained in:
Misha133
2022-12-14 09:57:06 +03:00
committed by GitHub
parent bd2f719774
commit 82b772ac03
14 changed files with 95 additions and 17 deletions

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

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> /// <summary>
/// Represents public flags for an application. /// Represents public flags for an application.
/// </summary> /// </summary>
public enum ApplicationFlags public enum ApplicationFlags
{ {
GatewayPresence = 1 << 12, GatewayPresence = 1 << 12,
GatewayPresenceLimited = 1 << 13, GatewayPresenceLimited = 1 << 13,
GatewayGuildMembers = 1 << 14, GatewayGuildMembers = 1 << 14,
GatewayGuildMembersLimited = 1 << 15, GatewayGuildMembersLimited = 1 << 15,
VerificationPendingGuildLimit = 1 << 16, VerificationPendingGuildLimit = 1 << 16,
Embedded = 1 << 17, Embedded = 1 << 17,
GatewayMessageContent = 1 << 18, GatewayMessageContent = 1 << 18,
GatewayMessageContentLimited = 1 << 19
} GatewayMessageContentLimited = 1 << 19,
ApplicationCommandBadge = 1 << 23,
ActiveApplication = 1 << 24
} }

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

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
}

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>

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>

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

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

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

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

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

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;

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

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>