Skip to content

Commit

Permalink
[Feature] Add missing property & new stuff (#2521)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Misha-133 committed Dec 14, 2022
1 parent bd2f719 commit 82b772a
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/Discord.Net.Core/DiscordErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public enum DiscordErrorCode
OwnershipCannotBeTransferredToABotUser = 50132,
FailedToResizeAssetBelowTheMaximumSize = 50138,
UploadedFileNotFound = 50146,
FeatureInProcessOfRollingOut = 50155,
MissingPermissionToSendThisSticker = 50600,
#endregion

Expand Down
41 changes: 26 additions & 15 deletions src/Discord.Net.Core/Entities/ApplicationFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,31 @@
using System.Text;
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
}

Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ public class ForumChannelProperties : TextChannelProperties
/// Gets or sets the rule used to order posts in forum channels.
/// </summary>
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 changes: 22 additions & 0 deletions src/Discord.Net.Core/Entities/Channels/ForumLayout.cs
Original file line number Diff line number Diff line change
@@ -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
}
7 changes: 6 additions & 1 deletion src/Discord.Net.Core/Entities/Channels/IForumChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ public interface IForumChannel : IGuildChannel, IMentionable, INestedChannel
IEmote DefaultReactionEmoji { get; }

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

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

/// <summary>
/// Modifies this forum channel.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Discord.Net.Core/Entities/Channels/IThreadChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public interface IThreadChannel : ITextChannel
/// </remarks>
new DateTimeOffset CreatedAt { get; }

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

/// <summary>
/// Joins the current thread.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Discord.Net.Core/Entities/Users/UserProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,10 @@ public enum UserProperties
/// Flag given to bots that use only outgoing webhooks, exclusively.
/// </summary>
BotHTTPInteractions = 1 << 19,

/// <summary>
/// Flag given to users that are active developers.
/// </summary>
ActiveDeveloper = 1 << 22
}
}
3 changes: 3 additions & 0 deletions src/Discord.Net.Rest/API/Common/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,8 @@ internal class Channel
[JsonProperty("default_reaction_emoji")]
public Optional<ForumReactionEmoji> DefaultReactionEmoji { get; set; }

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

}
}
3 changes: 3 additions & 0 deletions src/Discord.Net.Rest/API/Rest/ModifyForumChannelParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ internal class ModifyForumChannelParams : ModifyTextChannelParams

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

[JsonProperty("default_forum_layout")]
public Optional<ForumLayout> DefaultLayout { get; set; }
}
3 changes: 2 additions & 1 deletion src/Discord.Net.Rest/Entities/Channels/ForumHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ internal static class ForumHelper
emoji.Name : Optional<string>.Unspecified
}
: Optional<ModifyForumReactionEmojiParams>.Unspecified,
DefaultSortOrder = args.DefaultSortOrder
DefaultSortOrder = args.DefaultSortOrder,
DefaultLayout = args.DefaultLayout,
};
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class RestForumChannel : RestGuildChannel, IForumChannel
/// <inheritdoc/>
public ForumSortOrder? DefaultSortOrder { get; private set; }

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

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

Expand Down Expand Up @@ -87,6 +90,7 @@ internal override void Update(Model model)
}

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

/// <inheritdoc/>
Expand Down
5 changes: 5 additions & 0 deletions src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class RestThreadChannel : RestTextChannel, IThreadChannel
/// <inheritdoc/>
public IReadOnlyCollection<ulong> AppliedTags { get; private set; }

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

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

Expand Down Expand Up @@ -76,6 +79,8 @@ internal override void Update(Model model)
IsLocked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false);
}

OwnerId = model.OwnerId.GetValueOrDefault(0);

MemberCount = model.MemberCount.GetValueOrDefault(0);
MessageCount = model.MessageCount.GetValueOrDefault(0);
Type = (ThreadType)model.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class SocketForumChannel : SocketGuildChannel, IForumChannel
/// <inheritdoc/>
public ForumSortOrder? DefaultSortOrder { get; private set; }

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

/// <summary>
/// Gets the parent (category) of this channel in the guild's channel list.
/// </summary>
Expand Down Expand Up @@ -93,6 +96,8 @@ internal override void Update(ClientState state, Model model)
}

CategoryId = model.CategoryId.GetValueOrDefault();

DefaultLayout = model.DefaultForumLayout.GetValueOrDefault();
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public bool IsPrivateThread
/// <inheritdoc cref="IThreadChannel.CreatedAt"/>
public override DateTimeOffset CreatedAt { get; }

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

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

0 comments on commit 82b772a

Please sign in to comment.