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

@@ -5,6 +5,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -105,6 +106,11 @@ namespace Discord.WebSocket
public string Description { get; private set; }
/// <inheritdoc />
public int PremiumSubscriptionCount { get; private set; }
/// <inheritdoc />
public string PreferredLocale { get; private set; }
/// <inheritdoc />
public CultureInfo PreferredCulture { get; private set; }
/// <inheritdoc />
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
@@ -374,6 +380,8 @@ namespace Discord.WebSocket
SystemChannelFlags = model.SystemChannelFlags;
Description = model.Description;
PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault();
PreferredLocale = model.PreferredLocale;
PreferredCulture = new CultureInfo(PreferredLocale);
if (model.Emojis != null)
{