[Feature] Modify guild features (#2605)
* initial commit * Update src/Discord.Net.Core/Entities/Guilds/GuildProperties.cs --------- Co-authored-by: Casmir <68127614+csmir@users.noreply.github.com>
This commit is contained in:
@@ -34,11 +34,11 @@ namespace Discord
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Commerce = 1L << 4,
|
Commerce = 1L << 4,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates.
|
/// The guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates. This feature is mutable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Community = 1L << 5,
|
Community = 1L << 5,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The guild is able to be discovered in the directory.
|
/// The guild is able to be discovered in the directory. This feature is mutable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Discoverable = 1L << 6,
|
Discoverable = 1L << 6,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -185,5 +185,13 @@ namespace Discord
|
|||||||
/// The guild has been set as a support server on the App Directory.
|
/// The guild has been set as a support server on the App Directory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DeveloperSupportServer = 1L << 42,
|
DeveloperSupportServer = 1L << 42,
|
||||||
|
/// <summary>
|
||||||
|
/// The guild has invites disabled. This feature is mutable.
|
||||||
|
/// </summary>
|
||||||
|
InvitesDisabled = 1L << 43,
|
||||||
|
/// <summary>
|
||||||
|
/// The guild has auto moderation enabled.
|
||||||
|
/// </summary>
|
||||||
|
AutoModeration = 1L << 44
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,5 +113,10 @@ namespace Discord
|
|||||||
/// Gets or sets if the boost progress bar is enabled.
|
/// Gets or sets if the boost progress bar is enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Optional<bool> IsBoostProgressBarEnabled { get; set; }
|
public Optional<bool> IsBoostProgressBarEnabled { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,5 +37,7 @@ namespace Discord.API.Rest
|
|||||||
public string PreferredLocale { get; set; }
|
public string PreferredLocale { get; set; }
|
||||||
[JsonProperty("premium_progress_bar_enabled")]
|
[JsonProperty("premium_progress_bar_enabled")]
|
||||||
public Optional<bool> IsBoostProgressBarEnabled { get; set; }
|
public Optional<bool> IsBoostProgressBarEnabled { get; set; }
|
||||||
|
[JsonProperty("features")]
|
||||||
|
public Optional<GuildFeatures> GuildFeatures { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ namespace Discord.Rest
|
|||||||
VerificationLevel = args.VerificationLevel,
|
VerificationLevel = args.VerificationLevel,
|
||||||
ExplicitContentFilter = args.ExplicitContentFilter,
|
ExplicitContentFilter = args.ExplicitContentFilter,
|
||||||
SystemChannelFlags = args.SystemChannelFlags,
|
SystemChannelFlags = args.SystemChannelFlags,
|
||||||
IsBoostProgressBarEnabled = args.IsBoostProgressBarEnabled
|
IsBoostProgressBarEnabled = args.IsBoostProgressBarEnabled,
|
||||||
|
GuildFeatures = args.Features.IsSpecified ? new GuildFeatures(args.Features.Value, Array.Empty<string>()) : Optional.Create<GuildFeatures>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (apiArgs.Banner.IsSpecified)
|
if (apiArgs.Banner.IsSpecified)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using Newtonsoft.Json;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Discord.Net.Converters
|
namespace Discord.Net.Converters
|
||||||
{
|
{
|
||||||
@@ -36,9 +37,52 @@ namespace Discord.Net.Converters
|
|||||||
|
|
||||||
return new GuildFeatures(features, experimental.ToArray());
|
return new GuildFeatures(features, experimental.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var guildFeatures = (GuildFeatures)value;
|
||||||
|
|
||||||
|
var enumValues = Enum.GetValues(typeof(GuildFeature));
|
||||||
|
|
||||||
|
writer.WriteStartArray();
|
||||||
|
|
||||||
|
foreach (var enumValue in enumValues)
|
||||||
|
{
|
||||||
|
var val = (GuildFeature)enumValue;
|
||||||
|
if (val is GuildFeature.None)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (guildFeatures.Value.HasFlag(val))
|
||||||
|
{
|
||||||
|
writer.WriteValue(FeatureToApiString(val));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.WriteEndArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string FeatureToApiString(GuildFeature feature)
|
||||||
|
{
|
||||||
|
var builder = new StringBuilder();
|
||||||
|
var firstChar = true;
|
||||||
|
|
||||||
|
foreach (var c in feature.ToString().ToCharArray())
|
||||||
|
{
|
||||||
|
if (char.IsUpper(c))
|
||||||
|
{
|
||||||
|
if (firstChar)
|
||||||
|
firstChar = false;
|
||||||
|
else
|
||||||
|
builder.Append("_");
|
||||||
|
|
||||||
|
builder.Append(c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append(char.ToUpper(c));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user