feature: #1381 Guild PreferredLocale support (#1387)

* Fix #1381 Guild PreferredLocale support

Adds support for getting and modifying a guild's preferred_locale. This is a language tag in IETF BCP 47 format, which works with the built-in CultureInfo.

While Discord only supports a number of cultures, I think that this restriction should be handled at the API and not by the wrapper. (Also easier on our end)

* Add PreferredCulture to IGuild

This property was defined in RestGuild and SocketGuild, so it only makes sense to make it part of IGuild as well.
This commit is contained in:
Chris Johnston
2019-10-22 19:46:41 -07:00
committed by Christopher F
parent 0bda8a4217
commit a61adb07e0
7 changed files with 65 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
using System.Globalization;
namespace Discord
{
/// <summary>
@@ -84,5 +86,23 @@ namespace Discord
/// are enabled, without the need to manipulate the logic of the flag.
/// </remarks>
public Optional<SystemChannelMessageDeny> SystemChannelFlags { get; set; }
/// <summary>
/// Gets or sets the preferred locale of the guild in IETF BCP 47 language tag format.
/// </summary>
/// <remarks>
/// This property takes precedence over <see cref="PreferredCulture"/>.
/// When it is set, the value of <see cref="PreferredCulture"/>
/// will not be used.
/// </remarks>
public Optional<string> PreferredLocale { get; set; }
/// <summary>
/// Gets or sets the preferred locale of the guild.
/// </summary>
/// <remarks>
/// The <see cref="PreferredLocale"/> property takes precedence
/// over this property. When <see cref="PreferredLocale"/> is set,
/// the value of <see cref="PreferredCulture"/> will be unused.
/// </remarks>
public Optional<CultureInfo> PreferredCulture { get; set; }
}
}

View File

@@ -1,6 +1,7 @@
using Discord.Audio;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
namespace Discord
@@ -249,6 +250,24 @@ namespace Discord
/// </returns>
int PremiumSubscriptionCount { get; }
/// <summary>
/// Gets the preferred locale of this guild in IETF BCP 47
/// language tag format.
/// </summary>
/// <returns>
/// The preferred locale of the guild in IETF BCP 47
/// language tag format.
/// </returns>
string PreferredLocale { get; }
/// <summary>
/// Gets the preferred culture of this guild.
/// </summary>
/// <returns>
/// The preferred culture information of this guild.
/// </returns>
CultureInfo PreferredCulture { get; }
/// <summary>
/// Modifies this guild.
/// </summary>