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

@@ -68,6 +68,12 @@ namespace Discord.Rest
if (args.SystemChannelFlags.IsSpecified)
apiArgs.SystemChannelFlags = args.SystemChannelFlags.Value;
// PreferredLocale takes precedence over PreferredCulture
if (args.PreferredLocale.IsSpecified)
apiArgs.PreferredLocale = args.PreferredLocale.Value;
else if (args.PreferredCulture.IsSpecified)
apiArgs.PreferredLocale = args.PreferredCulture.Value.Name;
return await client.ApiClient.ModifyGuildAsync(guild.Id, apiArgs, options).ConfigureAwait(false);
}
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception>