Browse Source

Support Guild Boost Progress Bars (#262)

* Support Guild Boost Progress Bars

* Update SocketChannel.cs

* Fix non-optional and unnecessary values.

* Spelling

* Reordering and consistency.
pull/1923/head
CottageDwellingCat GitHub 3 years ago
parent
commit
caaad5e4a0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 4 deletions
  1. +4
    -0
      src/Discord.Net.Core/Entities/Guilds/GuildProperties.cs
  2. +7
    -0
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  3. +2
    -0
      src/Discord.Net.Rest/API/Common/Guild.cs
  4. +2
    -0
      src/Discord.Net.Rest/API/Rest/ModifyGuildParams.cs
  5. +2
    -1
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
  6. +4
    -0
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  7. +4
    -3
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 4
- 0
src/Discord.Net.Core/Entities/Guilds/GuildProperties.cs View File

@@ -108,5 +108,9 @@ namespace Discord
/// the value of <see cref="PreferredCulture"/> will be unused.
/// </remarks>
public Optional<CultureInfo> PreferredCulture { get; set; }
/// <summary>
/// Gets or sets if the boost progress bar is enabled.
/// </summary>
public Optional<bool> IsBoostProgressBarEnabled { get; set; }
}
}

+ 7
- 0
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -339,6 +339,13 @@ namespace Discord
/// The preferred culture information of this guild.
/// </returns>
CultureInfo PreferredCulture { get; }
/// <summary>
/// Gets whether the guild has the boost progress bar enabled.
/// </summary>
/// <returns>
/// <see langword="true"/> if the boost progress bar is enabled; otherwise <see langword="false"/>.
/// </returns>
bool IsBoostProgressBarEnabled { get; }

/// <summary>
/// Modifies this guild.


+ 2
- 0
src/Discord.Net.Rest/API/Common/Guild.cs View File

@@ -81,5 +81,7 @@ namespace Discord.API
public NsfwLevel NsfwLevel { get; set; }
[JsonProperty("stickers")]
public Sticker[] Stickers { get; set; }
[JsonProperty("premium_progress_bar_enabled")]
public Optional<bool> IsBoostProgressBarEnabled { get; set; }
}
}

+ 2
- 0
src/Discord.Net.Rest/API/Rest/ModifyGuildParams.cs View File

@@ -35,5 +35,7 @@ namespace Discord.API.Rest
public Optional<SystemChannelMessageDeny> SystemChannelFlags { get; set; }
[JsonProperty("preferred_locale")]
public string PreferredLocale { get; set; }
[JsonProperty("premium_progress_bar_enabled")]
public Optional<bool> IsBoostProgressBarEnabled { get; set; }
}
}

+ 2
- 1
src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs View File

@@ -36,7 +36,8 @@ namespace Discord.Rest
Banner = args.Banner.IsSpecified ? args.Banner.Value?.ToModel() : Optional.Create<ImageModel?>(),
VerificationLevel = args.VerificationLevel,
ExplicitContentFilter = args.ExplicitContentFilter,
SystemChannelFlags = args.SystemChannelFlags
SystemChannelFlags = args.SystemChannelFlags,
IsBoostProgressBarEnabled = args.IsBoostProgressBarEnabled
};

if (args.AfkChannel.IsSpecified)


+ 4
- 0
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -88,6 +88,8 @@ namespace Discord.Rest
public int? ApproximatePresenceCount { get; private set; }
/// <inheritdoc />
public NsfwLevel NsfwLevel { get; private set; }
/// <inheritdoc />
public bool IsBoostProgressBarEnabled { get; private set; }

/// <inheritdoc />
public CultureInfo PreferredCulture { get; private set; }
@@ -170,6 +172,8 @@ namespace Discord.Rest
ApproximateMemberCount = model.ApproximateMemberCount.Value;
if (model.ApproximatePresenceCount.IsSpecified)
ApproximatePresenceCount = model.ApproximatePresenceCount.Value;
if (model.IsBoostProgressBarEnabled.IsSpecified)
IsBoostProgressBarEnabled = model.IsBoostProgressBarEnabled.Value;

if (model.Emojis != null)
{


+ 4
- 3
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -125,9 +125,10 @@ namespace Discord.WebSocket
public int? MaxVideoChannelUsers { get; private set; }
/// <inheritdoc />
public NsfwLevel NsfwLevel { get; private set; }

/// <inheritdoc />
public CultureInfo PreferredCulture { get; private set; }
/// <inheritdoc />
public bool IsBoostProgressBarEnabled { get; private set; }

/// <inheritdoc />
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
@@ -495,7 +496,8 @@ namespace Discord.WebSocket
MaxVideoChannelUsers = model.MaxVideoChannelUsers.Value;
PreferredLocale = model.PreferredLocale;
PreferredCulture = PreferredLocale == null ? null : new CultureInfo(PreferredLocale);

if (model.IsBoostProgressBarEnabled.IsSpecified)
IsBoostProgressBarEnabled = model.IsBoostProgressBarEnabled.Value;
if (model.Emojis != null)
{
var emojis = ImmutableArray.CreateBuilder<GuildEmote>(model.Emojis.Length);
@@ -1627,7 +1629,6 @@ namespace Discord.WebSocket
int? IGuild.ApproximatePresenceCount => null;
/// <inheritdoc />
IReadOnlyCollection<ICustomSticker> IGuild.Stickers => Stickers;

/// <inheritdoc />
async Task<IReadOnlyCollection<IBan>> IGuild.GetBansAsync(RequestOptions options)
=> await GetBansAsync(options).ConfigureAwait(false);


Loading…
Cancel
Save