Browse Source

Add default reaction emoji property

pull/2469/head
Misha133 2 years ago
parent
commit
5d020cf11f
5 changed files with 50 additions and 0 deletions
  1. +9
    -0
      src/Discord.Net.Core/Entities/Channels/IForumChannel.cs
  2. +3
    -0
      src/Discord.Net.Rest/API/Common/Channel.cs
  3. +12
    -0
      src/Discord.Net.Rest/API/Common/ForumReactionEmoji.cs
  4. +13
    -0
      src/Discord.Net.Rest/Entities/Channels/RestForumChannel.cs
  5. +13
    -0
      src/Discord.Net.WebSocket/Entities/Channels/SocketForumChannel.cs

+ 9
- 0
src/Discord.Net.Core/Entities/Channels/IForumChannel.cs View File

@@ -53,6 +53,15 @@ namespace Discord
/// </returns> /// </returns>
int DefaultSlowModeInterval { get; } int DefaultSlowModeInterval { get; }


/// <summary>
/// Gets the emoji to show in the add reaction button on a thread in a forum channel
/// </summary>
/// <remarks>
/// If the emoji is <see cref="Emote"/> only the <see cref="Emote.Id"/> will be populated.
/// Use <see cref="IGuild.GetEmoteAsync"/> to get the emoji.
/// </remarks>
IEmote DefaultReactionEmoji { get; }

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


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

@@ -82,5 +82,8 @@ namespace Discord.API


[JsonProperty("flags")] [JsonProperty("flags")]
public Optional<ChannelFlags> Flags { get; set; } public Optional<ChannelFlags> Flags { get; set; }

[JsonProperty("default_reaction_emoji")]
public Optional<ForumReactionEmoji> DefaultReactionEmoji { get; set; }
} }
} }

+ 12
- 0
src/Discord.Net.Rest/API/Common/ForumReactionEmoji.cs View File

@@ -0,0 +1,12 @@
using Newtonsoft.Json;

namespace Discord.API;

public class ForumReactionEmoji
{
[JsonProperty("emoji_id")]
public Optional<ulong> EmojiId { get; set; }

[JsonProperty("emoji_name")]
public Optional<string> EmojiName { get; set; }
}

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

@@ -35,6 +35,9 @@ namespace Discord.Rest
/// <inheritdoc/> /// <inheritdoc/>
public ulong? CategoryId { get; private set; } public ulong? CategoryId { get; private set; }


/// <inheritdoc/>
public IEmote DefaultReactionEmoji { get; private set; }

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


@@ -67,6 +70,16 @@ namespace Discord.Rest
Tags = model.ForumTags.GetValueOrDefault(Array.Empty<API.ForumTags>()).Select( Tags = model.ForumTags.GetValueOrDefault(Array.Empty<API.ForumTags>()).Select(
x => new ForumTag(x.Id, x.Name, x.EmojiId.GetValueOrDefault(null), x.EmojiName.GetValueOrDefault(), x.Moderated) x => new ForumTag(x.Id, x.Name, x.EmojiId.GetValueOrDefault(null), x.EmojiName.GetValueOrDefault(), x.Moderated)
).ToImmutableArray(); ).ToImmutableArray();

if (model.DefaultReactionEmoji.IsSpecified)
{
if (model.DefaultReactionEmoji.Value.EmojiId.IsSpecified && model.DefaultReactionEmoji.Value.EmojiId.Value != 0)
DefaultReactionEmoji = new Emote(model.DefaultReactionEmoji.Value.EmojiId.Value, null, false);
else if (model.DefaultReactionEmoji.Value.EmojiName.IsSpecified)
DefaultReactionEmoji = new Emoji(model.DefaultReactionEmoji.Value.EmojiName.Value);
else
DefaultReactionEmoji = null;
}
} }


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


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

@@ -39,6 +39,9 @@ namespace Discord.WebSocket
/// <inheritdoc/> /// <inheritdoc/>
public ulong? CategoryId { get; private set; } public ulong? CategoryId { get; private set; }


/// <inheritdoc/>
public IEmote DefaultReactionEmoji { 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>
@@ -73,6 +76,16 @@ namespace Discord.WebSocket
Tags = model.ForumTags.GetValueOrDefault(Array.Empty<API.ForumTags>()).Select( Tags = model.ForumTags.GetValueOrDefault(Array.Empty<API.ForumTags>()).Select(
x => new ForumTag(x.Id, x.Name, x.EmojiId.GetValueOrDefault(null), x.EmojiName.GetValueOrDefault(), x.Moderated) x => new ForumTag(x.Id, x.Name, x.EmojiId.GetValueOrDefault(null), x.EmojiName.GetValueOrDefault(), x.Moderated)
).ToImmutableArray(); ).ToImmutableArray();

if (model.DefaultReactionEmoji.IsSpecified)
{
if (model.DefaultReactionEmoji.Value.EmojiId.IsSpecified && model.DefaultReactionEmoji.Value.EmojiId.Value != 0)
DefaultReactionEmoji = new Emote(model.DefaultReactionEmoji.Value.EmojiId.Value, null, false);
else if (model.DefaultReactionEmoji.Value.EmojiName.IsSpecified)
DefaultReactionEmoji = new Emoji(model.DefaultReactionEmoji.Value.EmojiName.Value);
else
DefaultReactionEmoji = null;
}
} }


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


Loading…
Cancel
Save