Skip to content

Commit 3bf8395

Browse files
committed
feat: invite guild profile
1 parent 07a8ac6 commit 3bf8395

File tree

5 files changed

+229
-1
lines changed

5 files changed

+229
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Newtonsoft.Json;
2+
3+
namespace DisCatSharp.Entities;
4+
5+
/// <summary>
6+
/// Represents a Discord game activity.
7+
/// </summary>
8+
public sealed class DiscordGameActivity
9+
{
10+
/// <summary>
11+
/// Gets the activity level.
12+
/// </summary>
13+
[JsonProperty("activity_level", NullValueHandling = NullValueHandling.Ignore)]
14+
public int ActivityLevel { get; set; }
15+
16+
/// <summary>
17+
/// Gets the activity score.
18+
/// </summary>
19+
[JsonProperty("activity_score", NullValueHandling = NullValueHandling.Ignore)]
20+
public int ActivityScore { get; set; }
21+
}
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
5+
using DisCatSharp.Enums;
6+
using DisCatSharp.Net;
7+
8+
using Newtonsoft.Json;
9+
10+
namespace DisCatSharp.Entities;
11+
12+
/// <summary>
13+
/// Represents a Discord guild profile.
14+
/// </summary>
15+
public sealed class DiscordGuildProfile : SnowflakeObject
16+
{
17+
/// <summary>
18+
/// Gets the guild name.
19+
/// </summary>
20+
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
21+
public string Name { get; internal set; }
22+
23+
/// <summary>
24+
/// Gets the guild icon's hash.
25+
/// </summary>
26+
[JsonProperty("icon", NullValueHandling = NullValueHandling.Include)]
27+
public string? IconHash { get; internal set; }
28+
29+
/// <summary>
30+
/// Gets the guild icon's url.
31+
/// </summary>
32+
[JsonIgnore]
33+
public string? IconUrl
34+
=> !string.IsNullOrWhiteSpace(this.IconHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.ICONS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.IconHash}.{(this.IconHash.StartsWith("a_", StringComparison.Ordinal) ? "gif" : "png")}?size=1024" : null;
35+
36+
/// <summary>
37+
/// Gets the guild banner's hash.
38+
/// </summary>
39+
[JsonProperty("banner", NullValueHandling = NullValueHandling.Include)]
40+
public string? BannerHash { get; internal set; }
41+
42+
/// <summary>
43+
/// Gets the guild banner's url.
44+
/// </summary>
45+
[JsonIgnore]
46+
public string? BannerUrl
47+
=> !string.IsNullOrWhiteSpace(this.BannerHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Uri}{Endpoints.BANNERS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.BannerHash}.{(this.BannerHash.StartsWith("a_", StringComparison.Ordinal) ? "gif" : "png")}" : null;
48+
49+
/// <summary>
50+
/// Gets the guild custom banner's hash.
51+
/// </summary>
52+
[JsonProperty("custom_banner", NullValueHandling = NullValueHandling.Include)]
53+
public string? CustomBannerHash { get; internal set; }
54+
55+
/// <summary>
56+
/// Gets the guild custom banner's url.
57+
/// </summary>
58+
[JsonIgnore]
59+
public string? CustomBannerUrl
60+
=> !string.IsNullOrWhiteSpace(this.CustomBannerHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Uri}{Endpoints.CUSTOM_BANNERS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.CustomBannerHash}.{(this.CustomBannerHash.StartsWith("a_", StringComparison.Ordinal) ? "gif" : "png")}" : null;
61+
62+
/// <summary>
63+
/// Gets the member count.
64+
/// </summary>
65+
[JsonProperty("member_count", NullValueHandling = NullValueHandling.Include)]
66+
public int? MemberCount { get; internal set; }
67+
68+
/// <summary>
69+
/// Gets the online count.
70+
/// </summary>
71+
[JsonProperty("online_count", NullValueHandling = NullValueHandling.Include)]
72+
public int? OnlineCount { get; internal set; }
73+
74+
/// <summary>
75+
/// Gets the guild description.
76+
/// </summary>
77+
[JsonProperty("description", NullValueHandling = NullValueHandling.Include)]
78+
public string? Description { get; internal set; }
79+
80+
/// <summary>
81+
/// Gets the primary brand color.
82+
/// </summary>
83+
[JsonProperty("brand_color_primary", NullValueHandling = NullValueHandling.Include)]
84+
public DiscordColor? BrandColorPrimary { get; internal set; }
85+
86+
/// <summary>
87+
/// Gets the primary badge color.
88+
/// </summary>
89+
[JsonProperty("badge_color_primary", NullValueHandling = NullValueHandling.Include)]
90+
public DiscordColor? BadgeColorPrimary { get; internal set; }
91+
92+
/// <summary>
93+
/// Gets the secondary badge color.
94+
/// </summary>
95+
[JsonProperty("badge_color_secondary", NullValueHandling = NullValueHandling.Include)]
96+
public DiscordColor? BadgeColorSecondary { get; internal set; }
97+
98+
/// <summary>
99+
/// Gets the badge hash.
100+
/// </summary>
101+
[JsonProperty("badge_hash", NullValueHandling = NullValueHandling.Include)]
102+
public string? BadgeHash { get; internal set; }
103+
104+
/// <summary>
105+
/// Gets the badge url.
106+
/// </summary>
107+
[JsonIgnore]
108+
public string? BadgeUrl
109+
=> !string.IsNullOrWhiteSpace(this.BadgeHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Uri}{Endpoints.BADGES}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.BadgeHash}.png" : null;
110+
111+
/// <summary>
112+
/// Gets the badge.
113+
/// </summary>
114+
[JsonProperty("badge", NullValueHandling = NullValueHandling.Ignore)]
115+
public int Badge { get; internal set; } = 0;
116+
117+
/// <summary>
118+
/// Gets the guild tag.
119+
/// </summary>
120+
[JsonProperty("tag", NullValueHandling = NullValueHandling.Include)]
121+
public string? Tag { get; internal set; }
122+
123+
/// <summary>
124+
/// Gets the game application IDs.
125+
/// </summary>
126+
[JsonProperty("game_application_ids", NullValueHandling = NullValueHandling.Ignore)]
127+
public IReadOnlyList<ulong> GameApplicationIds { get; internal set; } = [];
128+
129+
/// <summary>
130+
/// Gets the game activities.
131+
/// </summary>
132+
[JsonProperty("game_activity", NullValueHandling = NullValueHandling.Ignore)]
133+
public IReadOnlyDictionary<ulong, DiscordGameActivity> GameActivity { get; internal set; } = new Dictionary<ulong, DiscordGameActivity>();
134+
135+
/// <summary>
136+
/// Gets the traits.
137+
/// </summary>
138+
[JsonProperty("traits", NullValueHandling = NullValueHandling.Ignore)]
139+
public IReadOnlyList<DiscordGuildTrait> Traits { get; internal set; } = [];
140+
141+
/// <summary>
142+
/// Gets the features.
143+
/// </summary>
144+
[JsonProperty("features", NullValueHandling = NullValueHandling.Ignore)]
145+
public IReadOnlyList<string> Features { get; internal set; } = [];
146+
147+
/// <summary>
148+
/// <para>Gets the visibility.</para>
149+
/// <para><c>1</c> seems to be the default, for discovery, apply to join and invite only.</para>
150+
/// <para><c>3</c> seems to be for when you enabled <c>Apply From Profile</c> when having apply to join enabled.</para>
151+
/// </summary>
152+
[JsonProperty("visibility", NullValueHandling = NullValueHandling.Ignore)]
153+
public int Visibility { get; internal set; }
154+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Newtonsoft.Json;
2+
3+
namespace DisCatSharp.Entities;
4+
5+
/// <summary>
6+
/// Represents a Discord guild trait.
7+
/// </summary>
8+
public sealed class DiscordGuildTrait
9+
{
10+
/// <summary>
11+
/// Gets whether the emoji is animated.
12+
/// </summary>
13+
[JsonProperty("emoji_animated", NullValueHandling = NullValueHandling.Ignore)]
14+
public bool EmojiAnimated { get; internal set; }
15+
16+
/// <summary>
17+
/// Gets the emoji ID.
18+
/// </summary>
19+
[JsonProperty("emoji_id", NullValueHandling = NullValueHandling.Include)]
20+
public ulong? EmojiId { get; internal set; }
21+
22+
/// <summary>
23+
/// Gets the emoji name.
24+
/// </summary>
25+
[JsonProperty("emoji_name", NullValueHandling = NullValueHandling.Include)]
26+
public string? EmojiName { get; internal set; }
27+
28+
/// <summary>
29+
/// Gets the label.
30+
/// </summary>
31+
[JsonProperty("label", NullValueHandling = NullValueHandling.Ignore)]
32+
public string Label { get; internal set; }
33+
34+
/// <summary>
35+
/// Gets the position.
36+
/// </summary>
37+
[JsonProperty("position", NullValueHandling = NullValueHandling.Ignore)]
38+
public int Position { get; internal set; }
39+
}

DisCatSharp/Entities/Invite/DiscordInvite.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Threading.Tasks;
33

4+
using DisCatSharp.Attributes;
45
using DisCatSharp.Enums;
56
using DisCatSharp.Exceptions;
67

@@ -164,6 +165,12 @@ internal DiscordInvite()
164165
[JsonProperty("is_nickname_changeable", NullValueHandling = NullValueHandling.Ignore)]
165166
public bool? IsNicknameChangeable { get; internal set; } = null;
166167

168+
/// <summary>
169+
/// Gets the guild profile, if applicable.
170+
/// </summary>
171+
[JsonProperty("profile", NullValueHandling = NullValueHandling.Ignore), DiscordInExperiment, RequiresFeature(Features.Override, "Requires a newer super property hash.")]
172+
public DiscordGuildProfile? Profile { get; internal set; }
173+
167174
/// <summary>
168175
/// Deletes the invite.
169176
/// </summary>

DisCatSharp/Net/Rest/Endpoints.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,15 @@ public static class Endpoints
444444
public const string CHANNEL_ICONS = "/channel-icons";
445445

446446
/// <summary>
447-
/// The user banners endpoint.
447+
/// The banners endpoint.
448448
/// </summary>
449449
public const string BANNERS = "/banners";
450450

451+
/// <summary>
452+
/// The custom banners endpoint.
453+
/// </summary>
454+
public const string CUSTOM_BANNERS = "/custom-banners";
455+
451456
/// <summary>
452457
/// The sticker endpoint.
453458
/// This endpoint is the static nitro sticker application.
@@ -743,4 +748,6 @@ public static class Endpoints
743748
/// The consume endpoint.
744749
/// </summary>
745750
public const string CONSUME = "/consume";
751+
752+
public const string BADGES = "/badges";
746753
}

0 commit comments

Comments
 (0)