Skip to content

Commit

Permalink
[Feature] New discord features (#2649)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misha-133 committed Mar 31, 2023
1 parent 9ccd9cf commit 2112e1f
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/Discord.Net.Core/Entities/ApplicationFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace Discord;
/// </summary>
public enum ApplicationFlags
{
UsesAutoModApi = 1 << 6,

GatewayPresence = 1 << 12,

GatewayPresenceLimited = 1 << 13,
Expand Down
83 changes: 79 additions & 4 deletions src/Discord.Net.Core/Entities/Guilds/GuildFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,185 +13,260 @@ public enum GuildFeature : long
/// The guild has no features.
/// </summary>
None = 0L,

/// <summary>
/// The guild has access to animated banners.
/// </summary>
AnimatedBanner = 1L << 0,

/// <summary>
/// The guild has access to set an animated guild icon.
/// </summary>
AnimatedIcon = 1L << 1,

/// <summary>
/// The guild has access to set a guild banner image.
/// </summary>
Banner = 1L << 2,

/// <summary>
/// The guild has access to channel banners.
/// </summary>
ChannelBanner = 1L << 3,

/// <summary>
/// The guild has access to use commerce features (i.e. create store channels).
/// </summary>
Commerce = 1L << 4,

/// <summary>
/// The guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates. This feature is mutable.
/// The guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates.
/// </summary>
/// <remarks>
/// This feature is mutable.
/// </remarks>
Community = 1L << 5,

/// <summary>
/// The guild is able to be discovered in the directory. This feature is mutable.
/// The guild is able to be discovered in the directory.
/// </summary>
/// <remarks>
/// This feature is mutable.
/// </remarks>
Discoverable = 1L << 6,

/// <summary>
/// The guild has discoverable disabled.
/// </summary>
DiscoverableDisabled = 1L << 7,

/// <summary>
/// The guild has enabled discoverable before.
/// </summary>
EnabledDiscoverableBefore = 1L << 8,

/// <summary>
/// The guild is able to be featured in the directory.
/// </summary>
Featureable = 1L << 9,

/// <summary>
/// The guild has a force relay.
/// </summary>
ForceRelay = 1L << 10,

/// <summary>
/// The guild has a directory entry.
/// </summary>
HasDirectoryEntry = 1L << 11,

/// <summary>
/// The guild is a hub.
/// </summary>
Hub = 1L << 12,

/// <summary>
/// You shouldn't be here...
/// </summary>
InternalEmployeeOnly = 1L << 13,

/// <summary>
/// The guild has access to set an invite splash background.
/// </summary>
InviteSplash = 1L << 14,

/// <summary>
/// The guild is linked to a hub.
/// </summary>
LinkedToHub = 1L << 15,

/// <summary>
/// The guild has member profiles.
/// </summary>
MemberProfiles = 1L << 16,

/// <summary>
/// The guild has enabled <seealso href="https://discord.com/developers/docs/resources/guild#membership-screening-object">Membership Screening</seealso>.
/// </summary>
MemberVerificationGateEnabled = 1L << 17,

/// <summary>
/// The guild has enabled monetization.
/// </summary>
MonetizationEnabled = 1L << 18,

/// <summary>
/// The guild has more emojis.
/// </summary>
MoreEmoji = 1L << 19,

/// <summary>
/// The guild has increased custom sticker slots.
/// </summary>
MoreStickers = 1L << 20,

/// <summary>
/// The guild has access to create news channels.
/// </summary>
News = 1L << 21,

/// <summary>
/// The guild has new thread permissions.
/// </summary>
NewThreadPermissions = 1L << 22,

/// <summary>
/// The guild is partnered.
/// </summary>
Partnered = 1L << 23,

/// <summary>
/// The guild has a premium tier three override; guilds made by Discord usually have this.
/// </summary>
PremiumTier3Override = 1L << 24,

/// <summary>
/// The guild can be previewed before joining via Membership Screening or the directory.
/// </summary>
PreviewEnabled = 1L << 25,

/// <summary>
/// The guild has access to create private threads.
/// </summary>
PrivateThreads = 1L << 26,

/// <summary>
/// The guild has relay enabled.
/// </summary>
RelayEnabled = 1L << 27,

/// <summary>
/// The guild is able to set role icons.
/// </summary>
RoleIcons = 1L << 28,

/// <summary>
/// The guild has role subscriptions available for purchase.
/// </summary>
RoleSubscriptionsAvailableForPurchase = 1L << 29,

/// <summary>
/// The guild has role subscriptions enabled.
/// </summary>
RoleSubscriptionsEnabled = 1L << 30,

/// <summary>
/// The guild has access to the seven day archive time for threads.
/// </summary>
SevenDayThreadArchive = 1L << 31,

/// <summary>
/// The guild has text in voice enabled.
/// </summary>
TextInVoiceEnabled = 1L << 32,

/// <summary>
/// The guild has threads enabled.
/// </summary>
ThreadsEnabled = 1L << 33,

/// <summary>
/// The guild has testing threads enabled.
/// </summary>
ThreadsEnabledTesting = 1L << 34,

/// <summary>
/// The guild has the default thread auto archive.
/// </summary>
ThreadsDefaultAutoArchiveDuration = 1L << 35,

/// <summary>
/// The guild has access to the three day archive time for threads.
/// </summary>
ThreeDayThreadArchive = 1L << 36,

/// <summary>
/// The guild has enabled ticketed events.
/// </summary>
TicketedEventsEnabled = 1L << 37,

/// <summary>
/// The guild has access to set a vanity URL.
/// </summary>
VanityUrl = 1L << 38,

/// <summary>
/// The guild is verified.
/// </summary>
Verified = 1L << 39,

/// <summary>
/// The guild has access to set 384kbps bitrate in voice (previously VIP voice servers).
/// </summary>
VIPRegions = 1L << 40,

/// <summary>
/// The guild has enabled the welcome screen.
/// </summary>
WelcomeScreenEnabled = 1L << 41,

/// <summary>
/// The guild has been set as a support server on the App Directory.
/// </summary>
DeveloperSupportServer = 1L << 42,

/// <summary>
/// The guild has invites disabled. This feature is mutable.
/// The guild has invites disabled.
/// </summary>
/// <remarks>
/// This feature is mutable.
/// </remarks>
InvitesDisabled = 1L << 43,

/// <summary>
/// The guild has auto moderation enabled.
/// </summary>
AutoModeration = 1L << 44
AutoModeration = 1L << 44,

/// <summary>
/// This guild has alerts for join raids disabled.
/// </summary>
/// <remarks>
/// This feature is mutable.
/// </remarks>
RaidAlertsDisabled = 1L << 45,

/// <summary>
/// This guild has Clyde AI enabled.
/// </summary>
/// <remarks>
/// This feature is mutable.
/// </remarks>
ClydeEnabled = 1L << 46,

/// <summary>
/// This guild has a guild web page vanity url.
/// </summary>
GuildWebPageVanityUrl = 1L << 47
}
}
5 changes: 5 additions & 0 deletions src/Discord.Net.Core/Entities/Guilds/GuildProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,10 @@ public class GuildProperties
/// Gets or sets the guild features enabled in this guild. Features that are not mutable will be ignored.
/// </summary>
public Optional<GuildFeature> Features { get; set; }

/// <summary>
/// Gets or sets the ID of the safety alerts channel.
/// </summary>
public Optional<ulong> SafetyAlertsChannelId { get; set; }
}
}
8 changes: 8 additions & 0 deletions src/Discord.Net.Core/Entities/Guilds/IGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ public interface IGuild : IDeletable, ISnowflakeEntity
/// </returns>
ulong? WidgetChannelId { get; }
/// <summary>
/// Gets the ID of the channel assigned to the safety alerts channel of this guild.
/// </summary>
/// <returns>
/// A <see langword="ulong"/> representing the snowflake identifier of the safety alerts channel;
/// <see langword="null" /> if none is set.
/// </returns>
ulong? SafetyAlertsChannelId { get; }
/// <summary>
/// Gets the ID of the channel where randomized welcome messages are sent.
/// </summary>
/// <returns>
Expand Down
16 changes: 16 additions & 0 deletions src/Discord.Net.Core/Entities/Guilds/IUserGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,21 @@ public interface IUserGuild : IDeletable, ISnowflakeEntity
/// A flags enum containing all the features for the guild.
/// </returns>
GuildFeatures Features { get; }

/// <summary>
/// Gets the approximate number of members in this guild.
/// </summary>
/// <remarks>
/// Only available when getting a guild via REST when `with_counts` is true.
/// </remarks>
int? ApproximateMemberCount { get; }

/// <summary>
/// Gets the approximate number of non-offline members in this guild.
/// </summary>
/// <remarks>
/// Only available when getting a guild via REST when `with_counts` is true.
/// </remarks>
int? ApproximatePresenceCount { get; }
}
}
2 changes: 2 additions & 0 deletions src/Discord.Net.Rest/API/Common/Guild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ internal class Guild
public Optional<bool> WidgetEnabled { get; set; }
[JsonProperty("widget_channel_id")]
public Optional<ulong?> WidgetChannelId { get; set; }
[JsonProperty("safety_alerts_channel_id")]
public Optional<ulong?> SafetyAlertsChannelId { get; set; }
[JsonProperty("system_channel_id")]
public ulong? SystemChannelId { get; set; }
[JsonProperty("premium_tier")]
Expand Down
6 changes: 6 additions & 0 deletions src/Discord.Net.Rest/API/Common/UserGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ internal class UserGuild
public string Permissions { get; set; }
[JsonProperty("features")]
public GuildFeatures Features { get; set; }

[JsonProperty("approximate_member_count")]
public Optional<int> ApproximateMemberCount { get; set; }

[JsonProperty("approximate_presence_count")]
public Optional<int> ApproximatePresenceCount { get; set; }
}
}
2 changes: 2 additions & 0 deletions src/Discord.Net.Rest/API/Rest/ModifyGuildParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ internal class ModifyGuildParams
public Optional<Image?> Splash { get; set; }
[JsonProperty("afk_channel_id")]
public Optional<ulong?> AfkChannelId { get; set; }
[JsonProperty("safety_alerts_channel_id")]
public Optional<ulong> SafetyAlertsChannelId { get; set; }
[JsonProperty("owner_id")]
public Optional<ulong> OwnerId { get; set; }
[JsonProperty("explicit_content_filter")]
Expand Down
2 changes: 1 addition & 1 deletion src/Discord.Net.Rest/DiscordRestApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,7 @@ public async Task<IReadOnlyCollection<UserGuild>> GetMyGuildsAsync(GetGuildSumma
int limit = args.Limit.GetValueOrDefault(int.MaxValue);
ulong afterGuildId = args.AfterGuildId.GetValueOrDefault(0);

return await SendAsync<IReadOnlyCollection<UserGuild>>("GET", () => $"users/@me/guilds?limit={limit}&after={afterGuildId}", new BucketIds(), options: options).ConfigureAwait(false);
return await SendAsync<IReadOnlyCollection<UserGuild>>("GET", () => $"users/@me/guilds?limit={limit}&after={afterGuildId}&with_counts=true", new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<Application> GetMyApplicationAsync(RequestOptions options = null)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class RestGuild : RestEntity<ulong>, IGuild, IUpdateable
/// <inheritdoc />
public ulong? WidgetChannelId { get; private set; }
/// <inheritdoc />
public ulong? SafetyAlertsChannelId { get; private set; }
/// <inheritdoc />
public ulong? SystemChannelId { get; private set; }
/// <inheritdoc />
public ulong? RulesChannelId { get; private set; }
Expand Down Expand Up @@ -151,6 +153,8 @@ internal void Update(Model model)
AFKChannelId = model.AFKChannelId;
if (model.WidgetChannelId.IsSpecified)
WidgetChannelId = model.WidgetChannelId.Value;
if (model.SafetyAlertsChannelId.IsSpecified)
SafetyAlertsChannelId = model.SafetyAlertsChannelId.Value;
SystemChannelId = model.SystemChannelId;
RulesChannelId = model.RulesChannelId;
PublicUpdatesChannelId = model.PublicUpdatesChannelId;
Expand Down

0 comments on commit 2112e1f

Please sign in to comment.