[ifcbrk] feature: BOOST (#1319)

* add new MessageTypes

* Add new properties to the updated models

* add the SystemChannelMessageDeny

unsure if there would be a better name for this enum, given it's inverted nature, open for suggestions

* add PremiumTier flag, add Guild description property

* add method for getting vanity image from CDN

* make the size of GetGuildVanityUrl optional

* lint: remove commented out code from prev commit

* add a None flag to SystemChannelMessage enum

* implement the new modify guild params

* implement additional model properties in IGuild types

* implement GuildMember PremiumSince

* docs: reword size param explanation

* add extension methods that make it easier to check the SystemChannelMessage flags for end users

because the flag is inverted, this ideally should make it easier for the user. it may also be useful to do something similar for modifying this property

* docs: correct typo from copy-paste

* add the premium_subscription_count property

* fix vanity url code and banner switchup

a mistake was made somewhere, that's all I know for sure

* clarify remark on inverted logic for system channel flags

* fix PremiumSubscriptionCount optional value

* add another example to the systemchannelflags xmldoc remark

* docs: fix typos, clarify wording

* use DateTimeOffset for PremiumSince, follow conventions from other prop
This commit is contained in:
Chris Johnston
2019-06-21 14:34:45 -07:00
committed by Christopher F
parent d6d4429c3d
commit faf23dee35
18 changed files with 252 additions and 5 deletions

View File

@@ -45,5 +45,18 @@ namespace Discord.API
public ulong? ApplicationId { get; set; }
[JsonProperty("system_channel_id")]
public ulong? SystemChannelId { get; set; }
[JsonProperty("premium_tier")]
public PremiumTier PremiumTier { get; set; }
[JsonProperty("vanity_url_code")]
public string VanityURLCode { get; set; }
[JsonProperty("banner")]
public string Banner { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
// this value is inverted, flags set will turn OFF features
[JsonProperty("system_channel_flags")]
public SystemChannelMessageDeny SystemChannelFlags { get; set; }
[JsonProperty("premium_subscription_count")]
public int? PremiumSubscriptionCount { get; set; }
}
}

View File

@@ -1,4 +1,4 @@
#pragma warning disable CS1591
#pragma warning disable CS1591
using Newtonsoft.Json;
using System;
@@ -18,5 +18,7 @@ namespace Discord.API
public Optional<bool> Deaf { get; set; }
[JsonProperty("mute")]
public Optional<bool> Mute { get; set; }
[JsonProperty("premium_since")]
public Optional<DateTimeOffset?> PremiumSince { get; set; }
}
}

View File

@@ -30,5 +30,7 @@ namespace Discord.API.Rest
public Optional<ulong> OwnerId { get; set; }
[JsonProperty("explicit_content_filter")]
public Optional<ExplicitContentFilterLevel> ExplicitContentFilter { get; set; }
[JsonProperty("system_channel_flags")]
public Optional<SystemChannelMessageDeny> SystemChannelFlags { get; set; }
}
}

View File

@@ -33,7 +33,8 @@ namespace Discord.Rest
Name = args.Name,
Splash = args.Splash.IsSpecified ? args.Splash.Value?.ToModel() : Optional.Create<ImageModel?>(),
VerificationLevel = args.VerificationLevel,
ExplicitContentFilter = args.ExplicitContentFilter
ExplicitContentFilter = args.ExplicitContentFilter,
SystemChannelFlags = args.SystemChannelFlags
};
if (args.AfkChannel.IsSpecified)
@@ -64,6 +65,9 @@ namespace Discord.Rest
if (args.ExplicitContentFilter.IsSpecified)
apiArgs.ExplicitContentFilter = args.ExplicitContentFilter.Value;
if (args.SystemChannelFlags.IsSpecified)
apiArgs.SystemChannelFlags = args.SystemChannelFlags.Value;
return await client.ApiClient.ModifyGuildAsync(guild.Id, apiArgs, options).ConfigureAwait(false);
}
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception>

View File

@@ -52,6 +52,18 @@ namespace Discord.Rest
internal bool Available { get; private set; }
/// <inheritdoc />
public ulong? ApplicationId { get; private set; }
/// <inheritdoc />
public PremiumTier PremiumTier { get; private set; }
/// <inheritdoc />
public string BannerId { get; private set; }
/// <inheritdoc />
public string VanityURLCode { get; private set; }
/// <inheritdoc />
public SystemChannelMessageDeny SystemChannelFlags { get; private set; }
/// <inheritdoc />
public string Description { get; private set; }
/// <inheritdoc />
public int PremiumSubscriptionCount { get; private set; }
/// <inheritdoc />
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
@@ -62,6 +74,8 @@ namespace Discord.Rest
public string IconUrl => CDN.GetGuildIconUrl(Id, IconId);
/// <inheritdoc />
public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId);
/// <inheritdoc />
public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId);
/// <summary>
/// Gets the built-in role containing all users in this guild.
@@ -104,6 +118,12 @@ namespace Discord.Rest
DefaultMessageNotifications = model.DefaultMessageNotifications;
ExplicitContentFilter = model.ExplicitContentFilter;
ApplicationId = model.ApplicationId;
PremiumTier = model.PremiumTier;
VanityURLCode = model.VanityURLCode;
BannerId = model.Banner;
SystemChannelFlags = model.SystemChannelFlags;
Description = model.Description;
PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault();
if (model.Emojis != null)
{

View File

@@ -14,6 +14,7 @@ namespace Discord.Rest
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestGuildUser : RestUser, IGuildUser
{
private long? _premiumSinceTicks;
private long? _joinedAtTicks;
private ImmutableArray<ulong> _roleIds;
@@ -24,7 +25,8 @@ namespace Discord.Rest
public bool IsDeafened { get; private set; }
/// <inheritdoc />
public bool IsMuted { get; private set; }
/// <inheritdoc />
public DateTimeOffset? PremiumSince => DateTimeUtils.FromTicks(_premiumSinceTicks);
/// <inheritdoc />
public ulong GuildId => Guild.Id;
@@ -69,6 +71,8 @@ namespace Discord.Rest
IsMuted = model.Mute.Value;
if (model.Roles.IsSpecified)
UpdateRoles(model.Roles.Value);
if (model.PremiumSince.IsSpecified)
_premiumSinceTicks = model.PremiumSince.Value?.UtcTicks;
}
private void UpdateRoles(ulong[] roleIds)
{

View File

@@ -13,6 +13,8 @@ namespace Discord.Rest
/// <inheritdoc />
public ulong WebhookId { get; }
internal IGuild Guild { get; }
/// <inheritdoc />
public DateTimeOffset? PremiumSince { get; private set; }
/// <inheritdoc />
public override bool IsWebhook => true;