* Add missing properties to Guild, related methods, and deprecate GuildEmbed endpoints - Add missing guild properties: `discovery_splash`, `widget_enabled`, `widget_channel_id`, `rules_channel_id`, `max_presences`, `max_presences`, `max_members`, `public_updates_channel_id`, `max_video_channel_users`, `approximate_member_count`, `approximate_presence_count` - Update guild properties: `embed_enabled`, `embed_channel_id` - Add `GetGuildDiscoverySplashUrl` to `CDN` - Add classes related to the guild widget - Add `withCounts` parameter to `GetGuild(s)Async` - Make GuildEmbed related methods obsolete with a message redirecting to widget ones * Change xml docs and PremiumSubscriptionCount type * Changed some xml docspull/1682/head
@@ -73,11 +73,21 @@ namespace Discord | |||||
/// <param name="guildId">The guild snowflake identifier.</param> | /// <param name="guildId">The guild snowflake identifier.</param> | ||||
/// <param name="splashId">The splash icon identifier.</param> | /// <param name="splashId">The splash icon identifier.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A URL pointing to the guild's icon. | |||||
/// A URL pointing to the guild's splash. | |||||
/// </returns> | /// </returns> | ||||
public static string GetGuildSplashUrl(ulong guildId, string splashId) | public static string GetGuildSplashUrl(ulong guildId, string splashId) | ||||
=> splashId != null ? $"{DiscordConfig.CDNUrl}splashes/{guildId}/{splashId}.jpg" : null; | => splashId != null ? $"{DiscordConfig.CDNUrl}splashes/{guildId}/{splashId}.jpg" : null; | ||||
/// <summary> | /// <summary> | ||||
/// Returns a guild discovery splash URL. | |||||
/// </summary> | |||||
/// <param name="guildId">The guild snowflake identifier.</param> | |||||
/// <param name="discoverySplashId">The discovery splash icon identifier.</param> | |||||
/// <returns> | |||||
/// A URL pointing to the guild's discovery splash. | |||||
/// </returns> | |||||
public static string GetGuildDiscoverySplashUrl(ulong guildId, string discoverySplashId) | |||||
=> discoverySplashId != null ? $"{DiscordConfig.CDNUrl}discovery-splashes/{guildId}/{discoverySplashId}.jpg" : null; | |||||
/// <summary> | |||||
/// Returns a channel icon URL. | /// Returns a channel icon URL. | ||||
/// </summary> | /// </summary> | ||||
/// <param name="channelId">The channel snowflake identifier.</param> | /// <param name="channelId">The channel snowflake identifier.</param> | ||||
@@ -0,0 +1,21 @@ | |||||
namespace Discord | |||||
{ | |||||
/// <summary> | |||||
/// Provides properties that are used to modify the widget of an <see cref="IGuild" /> with the specified changes. | |||||
/// </summary> | |||||
public class GuildWidgetProperties | |||||
{ | |||||
/// <summary> | |||||
/// Sets whether the widget should be enabled. | |||||
/// </summary> | |||||
public Optional<bool> Enabled { get; set; } | |||||
/// <summary> | |||||
/// Sets the channel that the invite should place its users in, if not <see langword="null" />. | |||||
/// </summary> | |||||
public Optional<IChannel> Channel { get; set; } | |||||
/// <summary> | |||||
/// Sets the channel that the invite should place its users in, if not <see langword="null" />. | |||||
/// </summary> | |||||
public Optional<ulong?> ChannelId { get; set; } | |||||
} | |||||
} |
@@ -23,7 +23,7 @@ namespace Discord | |||||
/// automatically moved to the AFK voice channel. | /// automatically moved to the AFK voice channel. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// An <see cref="int"/> representing the amount of time in seconds for a user to be marked as inactive | |||||
/// An <see langword="int"/> representing the amount of time in seconds for a user to be marked as inactive | |||||
/// and moved into the AFK voice channel. | /// and moved into the AFK voice channel. | ||||
/// </returns> | /// </returns> | ||||
int AFKTimeout { get; } | int AFKTimeout { get; } | ||||
@@ -31,10 +31,17 @@ namespace Discord | |||||
/// Gets a value that indicates whether this guild is embeddable (i.e. can use widget). | /// Gets a value that indicates whether this guild is embeddable (i.e. can use widget). | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// <c>true</c> if this guild can be embedded via widgets; otherwise <c>false</c>. | |||||
/// <see langword="true" /> if this guild has a widget enabled; otherwise <see langword="false" />. | |||||
/// </returns> | /// </returns> | ||||
bool IsEmbeddable { get; } | bool IsEmbeddable { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets a value that indicates whether this guild has the widget enabled. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// <see langword="true" /> if this guild has a widget enabled; otherwise <see langword="false" />. | |||||
/// </returns> | |||||
bool IsWidgetEnabled { get; } | |||||
/// <summary> | |||||
/// Gets the default message notifications for users who haven't explicitly set their notification settings. | /// Gets the default message notifications for users who haven't explicitly set their notification settings. | ||||
/// </summary> | /// </summary> | ||||
DefaultMessageNotifications DefaultMessageNotifications { get; } | DefaultMessageNotifications DefaultMessageNotifications { get; } | ||||
@@ -64,31 +71,45 @@ namespace Discord | |||||
/// Gets the ID of this guild's icon. | /// Gets the ID of this guild's icon. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// An identifier for the splash image; <c>null</c> if none is set. | |||||
/// An identifier for the splash image; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
string IconId { get; } | string IconId { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the URL of this guild's icon. | /// Gets the URL of this guild's icon. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A URL pointing to the guild's icon; <c>null</c> if none is set. | |||||
/// A URL pointing to the guild's icon; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
string IconUrl { get; } | string IconUrl { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the ID of this guild's splash image. | /// Gets the ID of this guild's splash image. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// An identifier for the splash image; <c>null</c> if none is set. | |||||
/// An identifier for the splash image; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
string SplashId { get; } | string SplashId { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the URL of this guild's splash image. | /// Gets the URL of this guild's splash image. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A URL pointing to the guild's splash image; <c>null</c> if none is set. | |||||
/// A URL pointing to the guild's splash image; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
string SplashUrl { get; } | string SplashUrl { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the ID of this guild's discovery splash image. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// An identifier for the discovery splash image; <see langword="null" /> if none is set. | |||||
/// </returns> | |||||
string DiscoverySplashId { get; } | |||||
/// <summary> | |||||
/// Gets the URL of this guild's discovery splash image. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A URL pointing to the guild's discovery splash image; <see langword="null" /> if none is set. | |||||
/// </returns> | |||||
string DiscoverySplashUrl { get; } | |||||
/// <summary> | |||||
/// Determines if this guild is currently connected and ready to be used. | /// Determines if this guild is currently connected and ready to be used. | ||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
@@ -98,7 +119,7 @@ namespace Discord | |||||
/// This boolean is used to determine if the guild is currently connected to the WebSocket and is ready to be used/accessed. | /// This boolean is used to determine if the guild is currently connected to the WebSocket and is ready to be used/accessed. | ||||
/// </remarks> | /// </remarks> | ||||
/// <returns> | /// <returns> | ||||
/// <c>true</c> if this guild is currently connected and ready to be used; otherwise <c>false</c>. | |||||
/// <c>true</c> if this guild is currently connected and ready to be used; otherwise <see langword="false"/>. | |||||
/// </returns> | /// </returns> | ||||
bool Available { get; } | bool Available { get; } | ||||
@@ -106,7 +127,7 @@ namespace Discord | |||||
/// Gets the ID of the AFK voice channel for this guild. | /// Gets the ID of the AFK voice channel for this guild. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A <see cref="ulong"/> representing the snowflake identifier of the AFK voice channel; <c>null</c> if | |||||
/// A <see langword="ulong"/> representing the snowflake identifier of the AFK voice channel; <see langword="null" /> if | |||||
/// none is set. | /// none is set. | ||||
/// </returns> | /// </returns> | ||||
ulong? AFKChannelId { get; } | ulong? AFKChannelId { get; } | ||||
@@ -121,7 +142,7 @@ namespace Discord | |||||
/// </note> | /// </note> | ||||
/// </remarks> | /// </remarks> | ||||
/// <returns> | /// <returns> | ||||
/// A <see cref="ulong"/> representing the snowflake identifier of the default text channel; <c>0</c> if | |||||
/// A <see langword="ulong"/> representing the snowflake identifier of the default text channel; <c>0</c> if | |||||
/// none can be found. | /// none can be found. | ||||
/// </returns> | /// </returns> | ||||
ulong DefaultChannelId { get; } | ulong DefaultChannelId { get; } | ||||
@@ -129,30 +150,54 @@ namespace Discord | |||||
/// Gets the ID of the widget embed channel of this guild. | /// Gets the ID of the widget embed channel of this guild. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A <see cref="ulong"/> representing the snowflake identifier of the embedded channel found within the | |||||
/// widget settings of this guild; <c>null</c> if none is set. | |||||
/// A <see langword="ulong"/> representing the snowflake identifier of the embedded channel found within the | |||||
/// widget settings of this guild; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
ulong? EmbedChannelId { get; } | ulong? EmbedChannelId { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the ID of the channel assigned to the widget of this guild. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A <see langword="ulong"/> representing the snowflake identifier of the channel assigned to the widget found | |||||
/// within the widget settings of this guild; <see langword="null" /> if none is set. | |||||
/// </returns> | |||||
ulong? WidgetChannelId { get; } | |||||
/// <summary> | |||||
/// Gets the ID of the channel where randomized welcome messages are sent. | /// Gets the ID of the channel where randomized welcome messages are sent. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A <see cref="ulong"/> representing the snowflake identifier of the system channel where randomized | |||||
/// welcome messages are sent; <c>null</c> if none is set. | |||||
/// A <see langword="ulong"/> representing the snowflake identifier of the system channel where randomized | |||||
/// welcome messages are sent; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
ulong? SystemChannelId { get; } | ulong? SystemChannelId { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the ID of the channel with the rules. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A <see langword="ulong"/> representing the snowflake identifier of the channel that contains the rules; | |||||
/// <see langword="null" /> if none is set. | |||||
/// </returns> | |||||
ulong? RulesChannelId { get; } | |||||
/// <summary> | |||||
/// Gets the ID of the channel where admins and moderators of Community guilds receive notices from Discord. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A <see langword="ulong"/> representing the snowflake identifier of the channel where admins and moderators | |||||
/// of Community guilds receive notices from Discord; <see langword="null" /> if none is set. | |||||
/// </returns> | |||||
ulong? PublicUpdatesChannelId { get; } | |||||
/// <summary> | |||||
/// Gets the ID of the user that owns this guild. | /// Gets the ID of the user that owns this guild. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A <see cref="ulong"/> representing the snowflake identifier of the user that owns this guild. | |||||
/// A <see langword="ulong"/> representing the snowflake identifier of the user that owns this guild. | |||||
/// </returns> | /// </returns> | ||||
ulong OwnerId { get; } | ulong OwnerId { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the application ID of the guild creator if it is bot-created. | /// Gets the application ID of the guild creator if it is bot-created. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A <see cref="ulong"/> representing the snowflake identifier of the application ID that created this guild, or <c>null</c> if it was not bot-created. | |||||
/// A <see langword="ulong"/> representing the snowflake identifier of the application ID that created this guild, or <see langword="null" /> if it was not bot-created. | |||||
/// </returns> | /// </returns> | ||||
ulong? ApplicationId { get; } | ulong? ApplicationId { get; } | ||||
/// <summary> | /// <summary> | ||||
@@ -208,21 +253,21 @@ namespace Discord | |||||
/// Gets the identifier for this guilds banner image. | /// Gets the identifier for this guilds banner image. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// An identifier for the banner image; <c>null</c> if none is set. | |||||
/// An identifier for the banner image; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
string BannerId { get; } | string BannerId { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the URL of this guild's banner image. | /// Gets the URL of this guild's banner image. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A URL pointing to the guild's banner image; <c>null</c> if none is set. | |||||
/// A URL pointing to the guild's banner image; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
string BannerUrl { get; } | string BannerUrl { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the code for this guild's vanity invite URL. | /// Gets the code for this guild's vanity invite URL. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A string containing the vanity invite code for this guild; <c>null</c> if none is set. | |||||
/// A string containing the vanity invite code for this guild; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
string VanityURLCode { get; } | string VanityURLCode { get; } | ||||
/// <summary> | /// <summary> | ||||
@@ -236,7 +281,7 @@ namespace Discord | |||||
/// Gets the description for the guild. | /// Gets the description for the guild. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// The description for the guild; <c>null</c> if none is set. | |||||
/// The description for the guild; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
string Description { get; } | string Description { get; } | ||||
/// <summary> | /// <summary> | ||||
@@ -246,9 +291,50 @@ namespace Discord | |||||
/// This is the number of users who have boosted this guild. | /// This is the number of users who have boosted this guild. | ||||
/// </remarks> | /// </remarks> | ||||
/// <returns> | /// <returns> | ||||
/// The number of premium subscribers of this guild. | |||||
/// The number of premium subscribers of this guild; <see langword="null" /> if not available. | |||||
/// </returns> | /// </returns> | ||||
int PremiumSubscriptionCount { get; } | int PremiumSubscriptionCount { get; } | ||||
/// <summary> | |||||
/// Gets the maximum number of presences for the guild. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// The maximum number of presences for the guild. | |||||
/// </returns> | |||||
int? MaxPresences { get; } | |||||
/// <summary> | |||||
/// Gets the maximum number of members for the guild. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// The maximum number of members for the guild. | |||||
/// </returns> | |||||
int? MaxMembers { get; } | |||||
/// <summary> | |||||
/// Gets the maximum amount of users in a video channel. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// The maximum amount of users in a video channel. | |||||
/// </returns> | |||||
int? MaxVideoChannelUsers { get; } | |||||
/// <summary> | |||||
/// Gets the approximate number of members in this guild. | |||||
/// </summary> | |||||
/// <remarks> | |||||
/// Only available when getting a guild via REST when `with_counts` is true. | |||||
/// </remarks> | |||||
/// <returns> | |||||
/// The approximate number of members in this guild. | |||||
/// </returns> | |||||
int? ApproximateMemberCount { get; } | |||||
/// <summary> | |||||
/// Gets the approximate number of non-offline members in this guild. | |||||
/// </summary> | |||||
/// <remarks> | |||||
/// Only available when getting a guild via REST when `with_counts` is true. | |||||
/// </remarks> | |||||
/// <returns> | |||||
/// The approximate number of non-offline members in this guild. | |||||
/// </returns> | |||||
int? ApproximatePresenceCount { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets the preferred locale of this guild in IETF BCP 47 | /// Gets the preferred locale of this guild in IETF BCP 47 | ||||
@@ -285,8 +371,18 @@ namespace Discord | |||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous modification operation. | /// A task that represents the asynchronous modification operation. | ||||
/// </returns> | /// </returns> | ||||
[Obsolete("This endpoint is deprecated, use ModifyWidgetAsync instead.")] | |||||
Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null); | Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
/// Modifies this guild's widget. | |||||
/// </summary> | |||||
/// <param name="func">The delegate containing the properties to modify the guild widget with.</param> | |||||
/// <param name="options">The options to be used when sending the request.</param> | |||||
/// <returns> | |||||
/// A task that represents the asynchronous modification operation. | |||||
/// </returns> | |||||
Task ModifyWidgetAsync(Action<GuildWidgetProperties> func, RequestOptions options = null); | |||||
/// <summary> | |||||
/// Bulk-modifies the order of channels in this guild. | /// Bulk-modifies the order of channels in this guild. | ||||
/// </summary> | /// </summary> | ||||
/// <param name="args">The properties used to modify the channel positions with.</param> | /// <param name="args">The properties used to modify the channel positions with.</param> | ||||
@@ -336,7 +432,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains a ban object, which | /// A task that represents the asynchronous get operation. The task result contains a ban object, which | ||||
/// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | |||||
/// contains the user information and the reason for the ban; <see langword="null" /> if the ban entry cannot be found. | |||||
/// </returns> | /// </returns> | ||||
Task<IBan> GetBanAsync(IUser user, RequestOptions options = null); | Task<IBan> GetBanAsync(IUser user, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -346,7 +442,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains a ban object, which | /// A task that represents the asynchronous get operation. The task result contains a ban object, which | ||||
/// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | |||||
/// contains the user information and the reason for the ban; <see langword="null" /> if the ban entry cannot be found. | |||||
/// </returns> | /// </returns> | ||||
Task<IBan> GetBanAsync(ulong userId, RequestOptions options = null); | Task<IBan> GetBanAsync(ulong userId, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -410,7 +506,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the generic channel | /// A task that represents the asynchronous get operation. The task result contains the generic channel | ||||
/// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
/// </returns> | /// </returns> | ||||
Task<IGuildChannel> GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IGuildChannel> GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -431,7 +527,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the text channel | /// A task that represents the asynchronous get operation. The task result contains the text channel | ||||
/// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
/// </returns> | /// </returns> | ||||
Task<ITextChannel> GetTextChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<ITextChannel> GetTextChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -462,7 +558,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the voice channel associated | /// A task that represents the asynchronous get operation. The task result contains the voice channel associated | ||||
/// with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// with the specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
/// </returns> | /// </returns> | ||||
Task<IVoiceChannel> GetVoiceChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IVoiceChannel> GetVoiceChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -472,7 +568,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the voice channel that the | /// A task that represents the asynchronous get operation. The task result contains the voice channel that the | ||||
/// AFK users will be moved to after they have idled for too long; <c>null</c> if none is set. | |||||
/// AFK users will be moved to after they have idled for too long; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
Task<IVoiceChannel> GetAFKChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IVoiceChannel> GetAFKChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -482,7 +578,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the text channel where | /// A task that represents the asynchronous get operation. The task result contains the text channel where | ||||
/// randomized welcome messages will be sent to; <c>null</c> if none is set. | |||||
/// randomized welcome messages will be sent to; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
Task<ITextChannel> GetSystemChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<ITextChannel> GetSystemChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -492,7 +588,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the first viewable text | /// A task that represents the asynchronous get operation. The task result contains the first viewable text | ||||
/// channel in this guild; <c>null</c> if none is found. | |||||
/// channel in this guild; <see langword="null" /> if none is found. | |||||
/// </returns> | /// </returns> | ||||
Task<ITextChannel> GetDefaultChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<ITextChannel> GetDefaultChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -502,9 +598,40 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the embed channel set | /// A task that represents the asynchronous get operation. The task result contains the embed channel set | ||||
/// within the server's widget settings; <c>null</c> if none is set. | |||||
/// within the server's widget settings; <see langword="null" /> if none is set. | |||||
/// </returns> | /// </returns> | ||||
[Obsolete("This endpoint is deprecated, use GetWidgetChannelAsync instead.")] | |||||
Task<IGuildChannel> GetEmbedChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IGuildChannel> GetEmbedChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> | |||||
/// Gets the widget channel (i.e. the channel set in the guild's widget settings) in this guild. | |||||
/// </summary> | |||||
/// <param name="mode">The <see cref="CacheMode" /> that determines whether the object should be fetched from cache.</param> | |||||
/// <param name="options">The options to be used when sending the request.</param> | |||||
/// <returns> | |||||
/// A task that represents the asynchronous get operation. The task result contains the widget channel set | |||||
/// within the server's widget settings; <see langword="null" /> if none is set. | |||||
/// </returns> | |||||
Task<IGuildChannel> GetWidgetChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||||
/// <summary> | |||||
/// Gets the text channel where Community guilds can display rules and/or guidelines. | |||||
/// </summary> | |||||
/// <param name="mode">The <see cref="CacheMode"/> that determines whether the object should be fetched from cache.</param> | |||||
/// <param name="options">The options to be used when sending the request.</param> | |||||
/// <returns> | |||||
/// A task that represents the asynchronous get operation. The task result contains the text channel | |||||
/// where Community guilds can display rules and/or guidelines; <see langword="null" /> if none is set. | |||||
/// </returns> | |||||
Task<ITextChannel> GetRulesChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||||
/// <summary> | |||||
/// Gets the text channel channel where admins and moderators of Community guilds receive notices from Discord. | |||||
/// </summary> | |||||
/// <param name="mode">The <see cref="CacheMode"/> that determines whether the object should be fetched from cache.</param> | |||||
/// <param name="options">The options to be used when sending the request.</param> | |||||
/// <returns> | |||||
/// A task that represents the asynchronous get operation. The task result contains the text channel channel where | |||||
/// admins and moderators of Community guilds receive notices from Discord; <see langword="null" /> if none is set. | |||||
/// </returns> | |||||
Task<ITextChannel> GetPublicUpdatesChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||||
/// <summary> | /// <summary> | ||||
/// Creates a new text channel in this guild. | /// Creates a new text channel in this guild. | ||||
@@ -573,7 +700,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the partial metadata of | /// A task that represents the asynchronous get operation. The task result contains the partial metadata of | ||||
/// the vanity invite found within this guild; <c>null</c> if none is found. | |||||
/// the vanity invite found within this guild; <see langword="null" /> if none is found. | |||||
/// </returns> | /// </returns> | ||||
Task<IInviteMetadata> GetVanityInviteAsync(RequestOptions options = null); | Task<IInviteMetadata> GetVanityInviteAsync(RequestOptions options = null); | ||||
@@ -582,7 +709,7 @@ namespace Discord | |||||
/// </summary> | /// </summary> | ||||
/// <param name="id">The snowflake identifier for the role.</param> | /// <param name="id">The snowflake identifier for the role.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A role that is associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// A role that is associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
/// </returns> | /// </returns> | ||||
IRole GetRole(ulong id); | IRole GetRole(ulong id); | ||||
/// <summary> | /// <summary> | ||||
@@ -624,7 +751,7 @@ namespace Discord | |||||
/// <param name="accessToken">The OAuth2 access token for the user, requested with the guilds.join scope.</param> | /// <param name="accessToken">The OAuth2 access token for the user, requested with the guilds.join scope.</param> | ||||
/// <param name="func">The delegate containing the properties to be applied to the user upon being added to the guild.</param> | /// <param name="func">The delegate containing the properties to be applied to the user upon being added to the guild.</param> | ||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns>A guild user associated with the specified <paramref name="userId" />; <c>null</c> if the user is already in the guild.</returns> | |||||
/// <returns>A guild user associated with the specified <paramref name="userId" />; <see langword="null" /> if the user is already in the guild.</returns> | |||||
Task<IGuildUser> AddGuildUserAsync(ulong userId, string accessToken, Action<AddGuildUserProperties> func = null, RequestOptions options = null); | Task<IGuildUser> AddGuildUserAsync(ulong userId, string accessToken, Action<AddGuildUserProperties> func = null, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
/// Gets a collection of all users in this guild. | /// Gets a collection of all users in this guild. | ||||
@@ -649,7 +776,7 @@ namespace Discord | |||||
/// <remarks> | /// <remarks> | ||||
/// This method retrieves a user found within this guild. | /// This method retrieves a user found within this guild. | ||||
/// <note> | /// <note> | ||||
/// This may return <c>null</c> in the WebSocket implementation due to incomplete user collection in | |||||
/// This may return <see langword="null" /> in the WebSocket implementation due to incomplete user collection in | |||||
/// large guilds. | /// large guilds. | ||||
/// </note> | /// </note> | ||||
/// </remarks> | /// </remarks> | ||||
@@ -658,7 +785,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the guild user | /// A task that represents the asynchronous get operation. The task result contains the guild user | ||||
/// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
/// </returns> | /// </returns> | ||||
Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -752,7 +879,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the webhook with the | /// A task that represents the asynchronous get operation. The task result contains the webhook with the | ||||
/// specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
/// </returns> | /// </returns> | ||||
Task<IWebhook> GetWebhookAsync(ulong id, RequestOptions options = null); | Task<IWebhook> GetWebhookAsync(ulong id, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -772,7 +899,7 @@ namespace Discord | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the emote found with the | /// A task that represents the asynchronous get operation. The task result contains the emote found with the | ||||
/// specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// specified <paramref name="id"/>; <see langword="null" /> if none is found. | |||||
/// </returns> | /// </returns> | ||||
Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null); | Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -10,6 +10,7 @@ namespace Discord | |||||
/// <summary> | /// <summary> | ||||
/// Updates this object's properties with its current state. | /// Updates this object's properties with its current state. | ||||
/// </summary> | /// </summary> | ||||
/// <param name="options">The options to be used when sending the request.</param> | |||||
Task UpdateAsync(RequestOptions options = null); | Task UpdateAsync(RequestOptions options = null); | ||||
} | } | ||||
} | } |
@@ -13,6 +13,8 @@ namespace Discord.API | |||||
public string Icon { get; set; } | public string Icon { get; set; } | ||||
[JsonProperty("splash")] | [JsonProperty("splash")] | ||||
public string Splash { get; set; } | public string Splash { get; set; } | ||||
[JsonProperty("discovery_splash")] | |||||
public string DiscoverySplash { get; set; } | |||||
[JsonProperty("owner_id")] | [JsonProperty("owner_id")] | ||||
public ulong OwnerId { get; set; } | public ulong OwnerId { get; set; } | ||||
[JsonProperty("region")] | [JsonProperty("region")] | ||||
@@ -22,9 +24,9 @@ namespace Discord.API | |||||
[JsonProperty("afk_timeout")] | [JsonProperty("afk_timeout")] | ||||
public int AFKTimeout { get; set; } | public int AFKTimeout { get; set; } | ||||
[JsonProperty("embed_enabled")] | [JsonProperty("embed_enabled")] | ||||
public bool EmbedEnabled { get; set; } | |||||
public Optional<bool> EmbedEnabled { get; set; } | |||||
[JsonProperty("embed_channel_id")] | [JsonProperty("embed_channel_id")] | ||||
public ulong? EmbedChannelId { get; set; } | |||||
public Optional<ulong?> EmbedChannelId { get; set; } | |||||
[JsonProperty("verification_level")] | [JsonProperty("verification_level")] | ||||
public VerificationLevel VerificationLevel { get; set; } | public VerificationLevel VerificationLevel { get; set; } | ||||
[JsonProperty("default_message_notifications")] | [JsonProperty("default_message_notifications")] | ||||
@@ -43,6 +45,10 @@ namespace Discord.API | |||||
public MfaLevel MfaLevel { get; set; } | public MfaLevel MfaLevel { get; set; } | ||||
[JsonProperty("application_id")] | [JsonProperty("application_id")] | ||||
public ulong? ApplicationId { get; set; } | public ulong? ApplicationId { get; set; } | ||||
[JsonProperty("widget_enabled")] | |||||
public Optional<bool> WidgetEnabled { get; set; } | |||||
[JsonProperty("widget_channel_id")] | |||||
public Optional<ulong?> WidgetChannelId { get; set; } | |||||
[JsonProperty("system_channel_id")] | [JsonProperty("system_channel_id")] | ||||
public ulong? SystemChannelId { get; set; } | public ulong? SystemChannelId { get; set; } | ||||
[JsonProperty("premium_tier")] | [JsonProperty("premium_tier")] | ||||
@@ -56,9 +62,23 @@ namespace Discord.API | |||||
// this value is inverted, flags set will turn OFF features | // this value is inverted, flags set will turn OFF features | ||||
[JsonProperty("system_channel_flags")] | [JsonProperty("system_channel_flags")] | ||||
public SystemChannelMessageDeny SystemChannelFlags { get; set; } | public SystemChannelMessageDeny SystemChannelFlags { get; set; } | ||||
[JsonProperty("rules_channel_id")] | |||||
public ulong? RulesChannelId { get; set; } | |||||
[JsonProperty("max_presences")] | |||||
public Optional<int?> MaxPresences { get; set; } | |||||
[JsonProperty("max_members")] | |||||
public Optional<int> MaxMembers { get; set; } | |||||
[JsonProperty("premium_subscription_count")] | [JsonProperty("premium_subscription_count")] | ||||
public int? PremiumSubscriptionCount { get; set; } | |||||
public Optional<int> PremiumSubscriptionCount { get; set; } | |||||
[JsonProperty("preferred_locale")] | [JsonProperty("preferred_locale")] | ||||
public string PreferredLocale { get; set; } | public string PreferredLocale { get; set; } | ||||
[JsonProperty("public_updates_channel_id")] | |||||
public ulong? PublicUpdatesChannelId { get; set; } | |||||
[JsonProperty("max_video_channel_users")] | |||||
public Optional<int> MaxVideoChannelUsers { get; set; } | |||||
[JsonProperty("approximate_member_count")] | |||||
public Optional<int> ApproximateMemberCount { get; set; } | |||||
[JsonProperty("approximate_presence_count")] | |||||
public Optional<int> ApproximatePresenceCount { get; set; } | |||||
} | } | ||||
} | } |
@@ -0,0 +1,13 @@ | |||||
#pragma warning disable CS1591 | |||||
using Newtonsoft.Json; | |||||
namespace Discord.API | |||||
{ | |||||
internal class GuildWidget | |||||
{ | |||||
[JsonProperty("enabled")] | |||||
public bool Enabled { get; set; } | |||||
[JsonProperty("channel_id")] | |||||
public ulong? ChannelId { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,14 @@ | |||||
#pragma warning disable CS1591 | |||||
using Newtonsoft.Json; | |||||
namespace Discord.API.Rest | |||||
{ | |||||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)] | |||||
internal class ModifyGuildWidgetParams | |||||
{ | |||||
[JsonProperty("enabled")] | |||||
public Optional<bool> Enabled { get; set; } | |||||
[JsonProperty("channel")] | |||||
public Optional<ulong?> ChannelId { get; set; } | |||||
} | |||||
} |
@@ -62,9 +62,9 @@ namespace Discord.Rest | |||||
} | } | ||||
public static async Task<RestGuild> GetGuildAsync(BaseDiscordClient client, | public static async Task<RestGuild> GetGuildAsync(BaseDiscordClient client, | ||||
ulong id, RequestOptions options) | |||||
ulong id, bool withCounts, RequestOptions options) | |||||
{ | { | ||||
var model = await client.ApiClient.GetGuildAsync(id, options).ConfigureAwait(false); | |||||
var model = await client.ApiClient.GetGuildAsync(id, withCounts, options).ConfigureAwait(false); | |||||
if (model != null) | if (model != null) | ||||
return RestGuild.Create(client, model); | return RestGuild.Create(client, model); | ||||
return null; | return null; | ||||
@@ -77,6 +77,14 @@ namespace Discord.Rest | |||||
return RestGuildEmbed.Create(model); | return RestGuildEmbed.Create(model); | ||||
return null; | return null; | ||||
} | } | ||||
public static async Task<RestGuildWidget?> GetGuildWidgetAsync(BaseDiscordClient client, | |||||
ulong id, RequestOptions options) | |||||
{ | |||||
var model = await client.ApiClient.GetGuildWidgetAsync(id, options).ConfigureAwait(false); | |||||
if (model != null) | |||||
return RestGuildWidget.Create(model); | |||||
return null; | |||||
} | |||||
public static IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(BaseDiscordClient client, | public static IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(BaseDiscordClient client, | ||||
ulong? fromGuildId, int? limit, RequestOptions options) | ulong? fromGuildId, int? limit, RequestOptions options) | ||||
{ | { | ||||
@@ -106,13 +114,13 @@ namespace Discord.Rest | |||||
count: limit | count: limit | ||||
); | ); | ||||
} | } | ||||
public static async Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(BaseDiscordClient client, RequestOptions options) | |||||
public static async Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(BaseDiscordClient client, bool withCounts, RequestOptions options) | |||||
{ | { | ||||
var summaryModels = await GetGuildSummariesAsync(client, null, null, options).FlattenAsync().ConfigureAwait(false); | var summaryModels = await GetGuildSummariesAsync(client, null, null, options).FlattenAsync().ConfigureAwait(false); | ||||
var guilds = ImmutableArray.CreateBuilder<RestGuild>(); | var guilds = ImmutableArray.CreateBuilder<RestGuild>(); | ||||
foreach (var summaryModel in summaryModels) | foreach (var summaryModel in summaryModels) | ||||
{ | { | ||||
var guildModel = await client.ApiClient.GetGuildAsync(summaryModel.Id).ConfigureAwait(false); | |||||
var guildModel = await client.ApiClient.GetGuildAsync(summaryModel.Id, withCounts).ConfigureAwait(false); | |||||
if (guildModel != null) | if (guildModel != null) | ||||
guilds.Add(RestGuild.Create(client, guildModel)); | guilds.Add(RestGuild.Create(client, guildModel)); | ||||
} | } | ||||
@@ -140,7 +148,7 @@ namespace Discord.Rest | |||||
public static async Task<RestGuildUser> GetGuildUserAsync(BaseDiscordClient client, | public static async Task<RestGuildUser> GetGuildUserAsync(BaseDiscordClient client, | ||||
ulong guildId, ulong id, RequestOptions options) | ulong guildId, ulong id, RequestOptions options) | ||||
{ | { | ||||
var guild = await GetGuildAsync(client, guildId, options).ConfigureAwait(false); | |||||
var guild = await GetGuildAsync(client, guildId, false, options).ConfigureAwait(false); | |||||
if (guild == null) | if (guild == null) | ||||
return null; | return null; | ||||
@@ -787,7 +787,7 @@ namespace Discord.API | |||||
} | } | ||||
//Guilds | //Guilds | ||||
public async Task<Guild> GetGuildAsync(ulong guildId, RequestOptions options = null) | |||||
public async Task<Guild> GetGuildAsync(ulong guildId, bool withCounts, RequestOptions options = null) | |||||
{ | { | ||||
Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
@@ -795,7 +795,7 @@ namespace Discord.API | |||||
try | try | ||||
{ | { | ||||
var ids = new BucketIds(guildId: guildId); | var ids = new BucketIds(guildId: guildId); | ||||
return await SendAsync<Guild>("GET", () => $"guilds/{guildId}", ids, options: options).ConfigureAwait(false); | |||||
return await SendAsync<Guild>("GET", () => $"guilds/{guildId}?with_counts={(withCounts ? "true" : "false")}", ids, options: options).ConfigureAwait(false); | |||||
} | } | ||||
catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; } | catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; } | ||||
} | } | ||||
@@ -938,6 +938,32 @@ namespace Discord.API | |||||
return await SendJsonAsync<GuildEmbed>("PATCH", () => $"guilds/{guildId}/embed", args, ids, options: options).ConfigureAwait(false); | return await SendJsonAsync<GuildEmbed>("PATCH", () => $"guilds/{guildId}/embed", args, ids, options: options).ConfigureAwait(false); | ||||
} | } | ||||
//Guild Widget | |||||
/// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception> | |||||
public async Task<GuildWidget> GetGuildWidgetAsync(ulong guildId, RequestOptions options = null) | |||||
{ | |||||
Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||||
options = RequestOptions.CreateOrClone(options); | |||||
try | |||||
{ | |||||
var ids = new BucketIds(guildId: guildId); | |||||
return await SendAsync<GuildWidget>("GET", () => $"guilds/{guildId}/widget", ids, options: options).ConfigureAwait(false); | |||||
} | |||||
catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; } | |||||
} | |||||
/// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="args"/> must not be <see langword="null"/>.</exception> | |||||
public async Task<GuildWidget> ModifyGuildWidgetAsync(ulong guildId, Rest.ModifyGuildWidgetParams args, RequestOptions options = null) | |||||
{ | |||||
Preconditions.NotNull(args, nameof(args)); | |||||
Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||||
options = RequestOptions.CreateOrClone(options); | |||||
var ids = new BucketIds(guildId: guildId); | |||||
return await SendJsonAsync<GuildWidget>("PATCH", () => $"guilds/{guildId}/widget", args, ids, options: options).ConfigureAwait(false); | |||||
} | |||||
//Guild Integrations | //Guild Integrations | ||||
/// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception> | /// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception> | ||||
public async Task<IReadOnlyCollection<Integration>> GetGuildIntegrationsAsync(ulong guildId, RequestOptions options = null) | public async Task<IReadOnlyCollection<Integration>> GetGuildIntegrationsAsync(ulong guildId, RequestOptions options = null) | ||||
@@ -1,3 +1,4 @@ | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
using System.IO; | using System.IO; | ||||
@@ -76,15 +77,22 @@ namespace Discord.Rest | |||||
=> ClientHelper.GetInviteAsync(this, inviteId, options); | => ClientHelper.GetInviteAsync(this, inviteId, options); | ||||
public Task<RestGuild> GetGuildAsync(ulong id, RequestOptions options = null) | public Task<RestGuild> GetGuildAsync(ulong id, RequestOptions options = null) | ||||
=> ClientHelper.GetGuildAsync(this, id, options); | |||||
=> ClientHelper.GetGuildAsync(this, id, false, options); | |||||
public Task<RestGuild> GetGuildAsync(ulong id, bool withCounts, RequestOptions options = null) | |||||
=> ClientHelper.GetGuildAsync(this, id, withCounts, options); | |||||
[Obsolete("This endpoint is deprecated, use GetGuildWidgetAsync instead.")] | |||||
public Task<RestGuildEmbed?> GetGuildEmbedAsync(ulong id, RequestOptions options = null) | public Task<RestGuildEmbed?> GetGuildEmbedAsync(ulong id, RequestOptions options = null) | ||||
=> ClientHelper.GetGuildEmbedAsync(this, id, options); | => ClientHelper.GetGuildEmbedAsync(this, id, options); | ||||
public Task<RestGuildWidget?> GetGuildWidgetAsync(ulong id, RequestOptions options = null) | |||||
=> ClientHelper.GetGuildWidgetAsync(this, id, options); | |||||
public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(RequestOptions options = null) | ||||
=> ClientHelper.GetGuildSummariesAsync(this, null, null, options); | => ClientHelper.GetGuildSummariesAsync(this, null, null, options); | ||||
public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(ulong fromGuildId, int limit, RequestOptions options = null) | public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(ulong fromGuildId, int limit, RequestOptions options = null) | ||||
=> ClientHelper.GetGuildSummariesAsync(this, fromGuildId, limit, options); | => ClientHelper.GetGuildSummariesAsync(this, fromGuildId, limit, options); | ||||
public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(RequestOptions options = null) | ||||
=> ClientHelper.GetGuildsAsync(this, options); | |||||
=> ClientHelper.GetGuildsAsync(this, false, options); | |||||
public Task<IReadOnlyCollection<RestGuild>> GetGuildsAsync(bool withCounts, RequestOptions options = null) | |||||
=> ClientHelper.GetGuildsAsync(this, withCounts, options); | |||||
public Task<RestGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null) | public Task<RestGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null) | ||||
=> ClientHelper.CreateGuildAsync(this, name, region, jpegIcon, options); | => ClientHelper.CreateGuildAsync(this, name, region, jpegIcon, options); | ||||
@@ -5,6 +5,7 @@ using System.Collections.Immutable; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using EmbedModel = Discord.API.GuildEmbed; | using EmbedModel = Discord.API.GuildEmbed; | ||||
using WidgetModel = Discord.API.GuildWidget; | |||||
using Model = Discord.API.Guild; | using Model = Discord.API.Guild; | ||||
using RoleModel = Discord.API.Role; | using RoleModel = Discord.API.Role; | ||||
using ImageModel = Discord.API.Image; | using ImageModel = Discord.API.Image; | ||||
@@ -99,6 +100,27 @@ namespace Discord.Rest | |||||
return await client.ApiClient.ModifyGuildEmbedAsync(guild.Id, apiArgs, options).ConfigureAwait(false); | return await client.ApiClient.ModifyGuildEmbedAsync(guild.Id, apiArgs, options).ConfigureAwait(false); | ||||
} | } | ||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
public static async Task<WidgetModel> ModifyWidgetAsync(IGuild guild, BaseDiscordClient client, | |||||
Action<GuildWidgetProperties> func, RequestOptions options) | |||||
{ | |||||
if (func == null) | |||||
throw new ArgumentNullException(nameof(func)); | |||||
var args = new GuildWidgetProperties(); | |||||
func(args); | |||||
var apiArgs = new API.Rest.ModifyGuildWidgetParams | |||||
{ | |||||
Enabled = args.Enabled | |||||
}; | |||||
if (args.Channel.IsSpecified) | |||||
apiArgs.ChannelId = args.Channel.Value?.Id; | |||||
else if (args.ChannelId.IsSpecified) | |||||
apiArgs.ChannelId = args.ChannelId.Value; | |||||
return await client.ApiClient.ModifyGuildWidgetAsync(guild.Id, apiArgs, options).ConfigureAwait(false); | |||||
} | |||||
public static async Task ReorderChannelsAsync(IGuild guild, BaseDiscordClient client, | public static async Task ReorderChannelsAsync(IGuild guild, BaseDiscordClient client, | ||||
IEnumerable<ReorderChannelProperties> args, RequestOptions options) | IEnumerable<ReorderChannelProperties> args, RequestOptions options) | ||||
{ | { | ||||
@@ -7,6 +7,7 @@ using System.Globalization; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using EmbedModel = Discord.API.GuildEmbed; | using EmbedModel = Discord.API.GuildEmbed; | ||||
using WidgetModel = Discord.API.GuildWidget; | |||||
using Model = Discord.API.Guild; | using Model = Discord.API.Guild; | ||||
namespace Discord.Rest | namespace Discord.Rest | ||||
@@ -28,6 +29,8 @@ namespace Discord.Rest | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public bool IsEmbeddable { get; private set; } | public bool IsEmbeddable { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public bool IsWidgetEnabled { get; private set; } | |||||
/// <inheritdoc /> | |||||
public VerificationLevel VerificationLevel { get; private set; } | public VerificationLevel VerificationLevel { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public MfaLevel MfaLevel { get; private set; } | public MfaLevel MfaLevel { get; private set; } | ||||
@@ -41,8 +44,14 @@ namespace Discord.Rest | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public ulong? EmbedChannelId { get; private set; } | public ulong? EmbedChannelId { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public ulong? WidgetChannelId { get; private set; } | |||||
/// <inheritdoc /> | |||||
public ulong? SystemChannelId { get; private set; } | public ulong? SystemChannelId { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public ulong? RulesChannelId { get; private set; } | |||||
/// <inheritdoc /> | |||||
public ulong? PublicUpdatesChannelId { get; private set; } | |||||
/// <inheritdoc /> | |||||
public ulong OwnerId { get; private set; } | public ulong OwnerId { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string VoiceRegionId { get; private set; } | public string VoiceRegionId { get; private set; } | ||||
@@ -50,6 +59,8 @@ namespace Discord.Rest | |||||
public string IconId { get; private set; } | public string IconId { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string SplashId { get; private set; } | public string SplashId { get; private set; } | ||||
/// <inheritdoc /> | |||||
public string DiscoverySplashId { get; private set; } | |||||
internal bool Available { get; private set; } | internal bool Available { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public ulong? ApplicationId { get; private set; } | public ulong? ApplicationId { get; private set; } | ||||
@@ -67,6 +78,16 @@ namespace Discord.Rest | |||||
public int PremiumSubscriptionCount { get; private set; } | public int PremiumSubscriptionCount { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string PreferredLocale { get; private set; } | public string PreferredLocale { get; private set; } | ||||
/// <inheritdoc /> | |||||
public int? MaxPresences { get; private set; } | |||||
/// <inheritdoc /> | |||||
public int? MaxMembers { get; private set; } | |||||
/// <inheritdoc /> | |||||
public int? MaxVideoChannelUsers { get; private set; } | |||||
/// <inheritdoc /> | |||||
public int? ApproximateMemberCount { get; private set; } | |||||
/// <inheritdoc /> | |||||
public int? ApproximatePresenceCount { get; private set; } | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public CultureInfo PreferredCulture { get; private set; } | public CultureInfo PreferredCulture { get; private set; } | ||||
@@ -81,6 +102,8 @@ namespace Discord.Rest | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string DiscoverySplashUrl => CDN.GetGuildDiscoverySplashUrl(Id, DiscoverySplashId); | |||||
/// <inheritdoc /> | |||||
public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId); | public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId); | ||||
/// <summary> | /// <summary> | ||||
@@ -110,15 +133,24 @@ namespace Discord.Rest | |||||
internal void Update(Model model) | internal void Update(Model model) | ||||
{ | { | ||||
AFKChannelId = model.AFKChannelId; | AFKChannelId = model.AFKChannelId; | ||||
EmbedChannelId = model.EmbedChannelId; | |||||
if (model.EmbedChannelId.IsSpecified) | |||||
EmbedChannelId = model.EmbedChannelId.Value; | |||||
if (model.WidgetChannelId.IsSpecified) | |||||
WidgetChannelId = model.WidgetChannelId.Value; | |||||
SystemChannelId = model.SystemChannelId; | SystemChannelId = model.SystemChannelId; | ||||
RulesChannelId = model.RulesChannelId; | |||||
PublicUpdatesChannelId = model.PublicUpdatesChannelId; | |||||
AFKTimeout = model.AFKTimeout; | AFKTimeout = model.AFKTimeout; | ||||
IsEmbeddable = model.EmbedEnabled; | |||||
if (model.EmbedEnabled.IsSpecified) | |||||
IsEmbeddable = model.EmbedEnabled.Value; | |||||
if (model.WidgetEnabled.IsSpecified) | |||||
IsWidgetEnabled = model.WidgetEnabled.Value; | |||||
IconId = model.Icon; | IconId = model.Icon; | ||||
Name = model.Name; | Name = model.Name; | ||||
OwnerId = model.OwnerId; | OwnerId = model.OwnerId; | ||||
VoiceRegionId = model.Region; | VoiceRegionId = model.Region; | ||||
SplashId = model.Splash; | SplashId = model.Splash; | ||||
DiscoverySplashId = model.DiscoverySplash; | |||||
VerificationLevel = model.VerificationLevel; | VerificationLevel = model.VerificationLevel; | ||||
MfaLevel = model.MfaLevel; | MfaLevel = model.MfaLevel; | ||||
DefaultMessageNotifications = model.DefaultMessageNotifications; | DefaultMessageNotifications = model.DefaultMessageNotifications; | ||||
@@ -129,9 +161,20 @@ namespace Discord.Rest | |||||
BannerId = model.Banner; | BannerId = model.Banner; | ||||
SystemChannelFlags = model.SystemChannelFlags; | SystemChannelFlags = model.SystemChannelFlags; | ||||
Description = model.Description; | Description = model.Description; | ||||
PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault(); | |||||
if (model.PremiumSubscriptionCount.IsSpecified) | |||||
PremiumSubscriptionCount = model.PremiumSubscriptionCount.Value; | |||||
if (model.MaxPresences.IsSpecified) | |||||
MaxPresences = model.MaxPresences.Value ?? 25000; | |||||
if (model.MaxMembers.IsSpecified) | |||||
MaxMembers = model.MaxMembers.Value; | |||||
if (model.MaxVideoChannelUsers.IsSpecified) | |||||
MaxVideoChannelUsers = model.MaxVideoChannelUsers.Value; | |||||
PreferredLocale = model.PreferredLocale; | PreferredLocale = model.PreferredLocale; | ||||
PreferredCulture = new CultureInfo(PreferredLocale); | PreferredCulture = new CultureInfo(PreferredLocale); | ||||
if (model.ApproximateMemberCount.IsSpecified) | |||||
ApproximateMemberCount = model.ApproximateMemberCount.Value; | |||||
if (model.ApproximatePresenceCount.IsSpecified) | |||||
ApproximatePresenceCount = model.ApproximatePresenceCount.Value; | |||||
if (model.Emojis != null) | if (model.Emojis != null) | ||||
{ | { | ||||
@@ -163,17 +206,36 @@ namespace Discord.Rest | |||||
EmbedChannelId = model.ChannelId; | EmbedChannelId = model.ChannelId; | ||||
IsEmbeddable = model.Enabled; | IsEmbeddable = model.Enabled; | ||||
} | } | ||||
internal void Update(WidgetModel model) | |||||
{ | |||||
WidgetChannelId = model.ChannelId; | |||||
IsWidgetEnabled = model.Enabled; | |||||
} | |||||
//General | //General | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public async Task UpdateAsync(RequestOptions options = null) | public async Task UpdateAsync(RequestOptions options = null) | ||||
=> Update(await Discord.ApiClient.GetGuildAsync(Id, options).ConfigureAwait(false)); | |||||
=> Update(await Discord.ApiClient.GetGuildAsync(Id, false, options).ConfigureAwait(false)); | |||||
/// <summary> | |||||
/// Updates this object's properties with its current state. | |||||
/// </summary> | |||||
/// <param name="withCounts"> | |||||
/// If true, <see cref="ApproximateMemberCount"/> and <see cref="ApproximatePresenceCount"/> | |||||
/// will be updated as well. | |||||
/// </param> | |||||
/// <param name="options">The options to be used when sending the request.</param> | |||||
/// <remarks> | |||||
/// If <paramref name="withCounts"/> is true, <see cref="ApproximateMemberCount"/> and | |||||
/// <see cref="ApproximatePresenceCount"/> will be updated as well. | |||||
/// </remarks> | |||||
public async Task UpdateAsync(bool withCounts, RequestOptions options = null) | |||||
=> Update(await Discord.ApiClient.GetGuildAsync(Id, withCounts, options).ConfigureAwait(false)); | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public Task DeleteAsync(RequestOptions options = null) | public Task DeleteAsync(RequestOptions options = null) | ||||
=> GuildHelper.DeleteAsync(this, Discord, options); | => GuildHelper.DeleteAsync(this, Discord, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
public async Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null) | public async Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null) | ||||
{ | { | ||||
var model = await GuildHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); | var model = await GuildHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); | ||||
@@ -181,7 +243,8 @@ namespace Discord.Rest | |||||
} | } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
[Obsolete("This endpoint is deprecated, use ModifyWidgetAsync instead.")] | |||||
public async Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null) | public async Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null) | ||||
{ | { | ||||
var model = await GuildHelper.ModifyEmbedAsync(this, Discord, func, options).ConfigureAwait(false); | var model = await GuildHelper.ModifyEmbedAsync(this, Discord, func, options).ConfigureAwait(false); | ||||
@@ -189,7 +252,15 @@ namespace Discord.Rest | |||||
} | } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="ArgumentNullException"><paramref name="args" /> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
public async Task ModifyWidgetAsync(Action<GuildWidgetProperties> func, RequestOptions options = null) | |||||
{ | |||||
var model = await GuildHelper.ModifyWidgetAsync(this, Discord, func, options).ConfigureAwait(false); | |||||
Update(model); | |||||
} | |||||
/// <inheritdoc /> | |||||
/// <exception cref="ArgumentNullException"><paramref name="args" /> is <see langword="null"/>.</exception> | |||||
public async Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null) | public async Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null) | ||||
{ | { | ||||
var arr = args.ToArray(); | var arr = args.ToArray(); | ||||
@@ -230,7 +301,7 @@ namespace Discord.Rest | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains a ban object, which | /// A task that represents the asynchronous get operation. The task result contains a ban object, which | ||||
/// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | |||||
/// contains the user information and the reason for the ban; <see langword="null"/> if the ban entry cannot be found. | |||||
/// </returns> | /// </returns> | ||||
public Task<RestBan> GetBanAsync(IUser user, RequestOptions options = null) | public Task<RestBan> GetBanAsync(IUser user, RequestOptions options = null) | ||||
=> GuildHelper.GetBanAsync(this, Discord, user.Id, options); | => GuildHelper.GetBanAsync(this, Discord, user.Id, options); | ||||
@@ -241,7 +312,7 @@ namespace Discord.Rest | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains a ban object, which | /// A task that represents the asynchronous get operation. The task result contains a ban object, which | ||||
/// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | |||||
/// contains the user information and the reason for the ban; <see langword="null"/> if the ban entry cannot be found. | |||||
/// </returns> | /// </returns> | ||||
public Task<RestBan> GetBanAsync(ulong userId, RequestOptions options = null) | public Task<RestBan> GetBanAsync(ulong userId, RequestOptions options = null) | ||||
=> GuildHelper.GetBanAsync(this, Discord, userId, options); | => GuildHelper.GetBanAsync(this, Discord, userId, options); | ||||
@@ -279,7 +350,7 @@ namespace Discord.Rest | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the generic channel | /// A task that represents the asynchronous get operation. The task result contains the generic channel | ||||
/// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// associated with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public Task<RestGuildChannel> GetChannelAsync(ulong id, RequestOptions options = null) | public Task<RestGuildChannel> GetChannelAsync(ulong id, RequestOptions options = null) | ||||
=> GuildHelper.GetChannelAsync(this, Discord, id, options); | => GuildHelper.GetChannelAsync(this, Discord, id, options); | ||||
@@ -291,7 +362,7 @@ namespace Discord.Rest | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the text channel | /// A task that represents the asynchronous get operation. The task result contains the text channel | ||||
/// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// associated with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public async Task<RestTextChannel> GetTextChannelAsync(ulong id, RequestOptions options = null) | public async Task<RestTextChannel> GetTextChannelAsync(ulong id, RequestOptions options = null) | ||||
{ | { | ||||
@@ -320,7 +391,7 @@ namespace Discord.Rest | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the voice channel associated | /// A task that represents the asynchronous get operation. The task result contains the voice channel associated | ||||
/// with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public async Task<RestVoiceChannel> GetVoiceChannelAsync(ulong id, RequestOptions options = null) | public async Task<RestVoiceChannel> GetVoiceChannelAsync(ulong id, RequestOptions options = null) | ||||
{ | { | ||||
@@ -362,7 +433,7 @@ namespace Discord.Rest | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the voice channel that the | /// A task that represents the asynchronous get operation. The task result contains the voice channel that the | ||||
/// AFK users will be moved to after they have idled for too long; <c>null</c> if none is set. | |||||
/// AFK users will be moved to after they have idled for too long; <see langword="null"/> if none is set. | |||||
/// </returns> | /// </returns> | ||||
public async Task<RestVoiceChannel> GetAFKChannelAsync(RequestOptions options = null) | public async Task<RestVoiceChannel> GetAFKChannelAsync(RequestOptions options = null) | ||||
{ | { | ||||
@@ -381,7 +452,7 @@ namespace Discord.Rest | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the first viewable text | /// A task that represents the asynchronous get operation. The task result contains the first viewable text | ||||
/// channel in this guild; <c>null</c> if none is found. | |||||
/// channel in this guild; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public async Task<RestTextChannel> GetDefaultChannelAsync(RequestOptions options = null) | public async Task<RestTextChannel> GetDefaultChannelAsync(RequestOptions options = null) | ||||
{ | { | ||||
@@ -399,8 +470,9 @@ namespace Discord.Rest | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the embed channel set | /// A task that represents the asynchronous get operation. The task result contains the embed channel set | ||||
/// within the server's widget settings; <c>null</c> if none is set. | |||||
/// within the server's widget settings; <see langword="null"/> if none is set. | |||||
/// </returns> | /// </returns> | ||||
[Obsolete("This endpoint is deprecated, use GetWidgetChannelAsync instead.")] | |||||
public async Task<RestGuildChannel> GetEmbedChannelAsync(RequestOptions options = null) | public async Task<RestGuildChannel> GetEmbedChannelAsync(RequestOptions options = null) | ||||
{ | { | ||||
var embedId = EmbedChannelId; | var embedId = EmbedChannelId; | ||||
@@ -410,12 +482,28 @@ namespace Discord.Rest | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the first viewable text channel in this guild. | |||||
/// Gets the widget channel (i.e. the channel set in the guild's widget settings) in this guild. | |||||
/// </summary> | /// </summary> | ||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the first viewable text | |||||
/// channel in this guild; <c>null</c> if none is found. | |||||
/// A task that represents the asynchronous get operation. The task result contains the widget channel set | |||||
/// within the server's widget settings; <see langword="null"/> if none is set. | |||||
/// </returns> | |||||
public async Task<RestGuildChannel> GetWidgetChannelAsync(RequestOptions options = null) | |||||
{ | |||||
var widgetChannelId = WidgetChannelId; | |||||
if (widgetChannelId.HasValue) | |||||
return await GuildHelper.GetChannelAsync(this, Discord, widgetChannelId.Value, options).ConfigureAwait(false); | |||||
return null; | |||||
} | |||||
/// <summary> | |||||
/// Gets the text channel where guild notices such as welcome messages and boost events are posted. | |||||
/// </summary> | |||||
/// <param name="options">The options to be used when sending the request.</param> | |||||
/// <returns> | |||||
/// A task that represents the asynchronous get operation. The task result contains the text channel | |||||
/// where guild notices such as welcome messages and boost events are poste; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public async Task<RestTextChannel> GetSystemChannelAsync(RequestOptions options = null) | public async Task<RestTextChannel> GetSystemChannelAsync(RequestOptions options = null) | ||||
{ | { | ||||
@@ -427,6 +515,45 @@ namespace Discord.Rest | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
/// <summary> | |||||
/// Gets the text channel where Community guilds can display rules and/or guidelines. | |||||
/// </summary> | |||||
/// <param name="options">The options to be used when sending the request.</param> | |||||
/// <returns> | |||||
/// A task that represents the asynchronous get operation. The task result contains the text channel | |||||
/// where Community guilds can display rules and/or guidelines; <see langword="null"/> if none is set. | |||||
/// </returns> | |||||
public async Task<RestTextChannel> GetRulesChannelAsync(RequestOptions options = null) | |||||
{ | |||||
var rulesChannelId = RulesChannelId; | |||||
if (rulesChannelId.HasValue) | |||||
{ | |||||
var channel = await GuildHelper.GetChannelAsync(this, Discord, rulesChannelId.Value, options).ConfigureAwait(false); | |||||
return channel as RestTextChannel; | |||||
} | |||||
return null; | |||||
} | |||||
/// <summary> | |||||
/// Gets the text channel channel where admins and moderators of Community guilds receive notices from Discord. | |||||
/// </summary> | |||||
/// <param name="options">The options to be used when sending the request.</param> | |||||
/// <returns> | |||||
/// A task that represents the asynchronous get operation. The task result contains the text channel channel where | |||||
/// admins and moderators of Community guilds receive notices from Discord; <see langword="null"/> if none is set. | |||||
/// </returns> | |||||
public async Task<RestTextChannel> GetPublicUpdatesChannelAsync(RequestOptions options = null) | |||||
{ | |||||
var publicUpdatesChannelId = PublicUpdatesChannelId; | |||||
if (publicUpdatesChannelId.HasValue) | |||||
{ | |||||
var channel = await GuildHelper.GetChannelAsync(this, Discord, publicUpdatesChannelId.Value, options).ConfigureAwait(false); | |||||
return channel as RestTextChannel; | |||||
} | |||||
return null; | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// Creates a new text channel in this guild. | /// Creates a new text channel in this guild. | ||||
/// </summary> | /// </summary> | ||||
@@ -458,7 +585,7 @@ namespace Discord.Rest | |||||
/// <param name="name">The name of the new channel.</param> | /// <param name="name">The name of the new channel.</param> | ||||
/// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | ||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="name" /> is <see langword="null"/>.</exception> | |||||
/// <returns> | /// <returns> | ||||
/// The created voice channel. | /// The created voice channel. | ||||
/// </returns> | /// </returns> | ||||
@@ -470,7 +597,7 @@ namespace Discord.Rest | |||||
/// <param name="name">The name of the new channel.</param> | /// <param name="name">The name of the new channel.</param> | ||||
/// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | ||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="name" /> is <see langword="null"/>.</exception> | |||||
/// <returns> | /// <returns> | ||||
/// The created category channel. | /// The created category channel. | ||||
/// </returns> | /// </returns> | ||||
@@ -521,7 +648,7 @@ namespace Discord.Rest | |||||
/// </summary> | /// </summary> | ||||
/// <param name="id">The snowflake identifier for the role.</param> | /// <param name="id">The snowflake identifier for the role.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A role that is associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// A role that is associated with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public RestRole GetRole(ulong id) | public RestRole GetRole(ulong id) | ||||
{ | { | ||||
@@ -585,7 +712,7 @@ namespace Discord.Rest | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the guild user | /// A task that represents the asynchronous get operation. The task result contains the guild user | ||||
/// associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// associated with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public Task<RestGuildUser> GetUserAsync(ulong id, RequestOptions options = null) | public Task<RestGuildUser> GetUserAsync(ulong id, RequestOptions options = null) | ||||
=> GuildHelper.GetUserAsync(this, Discord, id, options); | => GuildHelper.GetUserAsync(this, Discord, id, options); | ||||
@@ -675,7 +802,7 @@ namespace Discord.Rest | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the webhook with the | /// A task that represents the asynchronous get operation. The task result contains the webhook with the | ||||
/// specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | ||||
=> GuildHelper.GetWebhookAsync(this, Discord, id, options); | => GuildHelper.GetWebhookAsync(this, Discord, id, options); | ||||
@@ -708,7 +835,7 @@ namespace Discord.Rest | |||||
public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null) | public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null) | ||||
=> GuildHelper.CreateEmoteAsync(this, Discord, name, image, roles, options); | => GuildHelper.CreateEmoteAsync(this, Discord, name, image, roles, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null) | public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null) | ||||
=> GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options); | => GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
@@ -808,6 +935,7 @@ namespace Discord.Rest | |||||
return null; | return null; | ||||
} | } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
[Obsolete("This endpoint is deprecated, use GetWidgetChannelAsync instead.")] | |||||
async Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options) | async Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options) | ||||
{ | { | ||||
if (mode == CacheMode.AllowDownload) | if (mode == CacheMode.AllowDownload) | ||||
@@ -816,6 +944,14 @@ namespace Discord.Rest | |||||
return null; | return null; | ||||
} | } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
async Task<IGuildChannel> IGuild.GetWidgetChannelAsync(CacheMode mode, RequestOptions options) | |||||
{ | |||||
if (mode == CacheMode.AllowDownload) | |||||
return await GetWidgetChannelAsync(options).ConfigureAwait(false); | |||||
else | |||||
return null; | |||||
} | |||||
/// <inheritdoc /> | |||||
async Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options) | async Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options) | ||||
{ | { | ||||
if (mode == CacheMode.AllowDownload) | if (mode == CacheMode.AllowDownload) | ||||
@@ -824,6 +960,22 @@ namespace Discord.Rest | |||||
return null; | return null; | ||||
} | } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
async Task<ITextChannel> IGuild.GetRulesChannelAsync(CacheMode mode, RequestOptions options) | |||||
{ | |||||
if (mode == CacheMode.AllowDownload) | |||||
return await GetRulesChannelAsync(options).ConfigureAwait(false); | |||||
else | |||||
return null; | |||||
} | |||||
/// <inheritdoc /> | |||||
async Task<ITextChannel> IGuild.GetPublicUpdatesChannelAsync(CacheMode mode, RequestOptions options) | |||||
{ | |||||
if (mode == CacheMode.AllowDownload) | |||||
return await GetPublicUpdatesChannelAsync(options).ConfigureAwait(false); | |||||
else | |||||
return null; | |||||
} | |||||
/// <inheritdoc /> | |||||
async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, Action<TextChannelProperties> func, RequestOptions options) | async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, Action<TextChannelProperties> func, RequestOptions options) | ||||
=> await CreateTextChannelAsync(name, func, options).ConfigureAwait(false); | => await CreateTextChannelAsync(name, func, options).ConfigureAwait(false); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
@@ -0,0 +1,25 @@ | |||||
using System.Diagnostics; | |||||
using Model = Discord.API.GuildWidget; | |||||
namespace Discord.Rest | |||||
{ | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | |||||
public struct RestGuildWidget | |||||
{ | |||||
public bool IsEnabled { get; private set; } | |||||
public ulong? ChannelId { get; private set; } | |||||
internal RestGuildWidget(bool isEnabled, ulong? channelId) | |||||
{ | |||||
ChannelId = channelId; | |||||
IsEnabled = isEnabled; | |||||
} | |||||
internal static RestGuildWidget Create(Model model) | |||||
{ | |||||
return new RestGuildWidget(model.Enabled, model.ChannelId); | |||||
} | |||||
public override string ToString() => ChannelId?.ToString() ?? "Unknown"; | |||||
private string DebuggerDisplay => $"{ChannelId} ({(IsEnabled ? "Enabled" : "Disabled")})"; | |||||
} | |||||
} |
@@ -48,6 +48,8 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public bool IsEmbeddable { get; private set; } | public bool IsEmbeddable { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public bool IsWidgetEnabled { get; private set; } | |||||
/// <inheritdoc /> | |||||
public VerificationLevel VerificationLevel { get; private set; } | public VerificationLevel VerificationLevel { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public MfaLevel MfaLevel { get; private set; } | public MfaLevel MfaLevel { get; private set; } | ||||
@@ -83,7 +85,10 @@ namespace Discord.WebSocket | |||||
internal ulong? AFKChannelId { get; private set; } | internal ulong? AFKChannelId { get; private set; } | ||||
internal ulong? EmbedChannelId { get; private set; } | internal ulong? EmbedChannelId { get; private set; } | ||||
internal ulong? WidgetChannelId { get; private set; } | |||||
internal ulong? SystemChannelId { get; private set; } | internal ulong? SystemChannelId { get; private set; } | ||||
internal ulong? RulesChannelId { get; private set; } | |||||
internal ulong? PublicUpdatesChannelId { get; private set; } | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public ulong OwnerId { get; private set; } | public ulong OwnerId { get; private set; } | ||||
/// <summary> Gets the user that owns this guild. </summary> | /// <summary> Gets the user that owns this guild. </summary> | ||||
@@ -95,6 +100,8 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string SplashId { get; private set; } | public string SplashId { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string DiscoverySplashId { get; private set; } | |||||
/// <inheritdoc /> | |||||
public PremiumTier PremiumTier { get; private set; } | public PremiumTier PremiumTier { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string BannerId { get; private set; } | public string BannerId { get; private set; } | ||||
@@ -108,6 +115,12 @@ namespace Discord.WebSocket | |||||
public int PremiumSubscriptionCount { get; private set; } | public int PremiumSubscriptionCount { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string PreferredLocale { get; private set; } | public string PreferredLocale { get; private set; } | ||||
/// <inheritdoc /> | |||||
public int? MaxPresences { get; private set; } | |||||
/// <inheritdoc /> | |||||
public int? MaxMembers { get; private set; } | |||||
/// <inheritdoc /> | |||||
public int? MaxVideoChannelUsers { get; private set; } | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public CultureInfo PreferredCulture { get; private set; } | public CultureInfo PreferredCulture { get; private set; } | ||||
@@ -119,6 +132,8 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string DiscoverySplashUrl => CDN.GetGuildDiscoverySplashUrl(Id, DiscoverySplashId); | |||||
/// <inheritdoc /> | |||||
public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId); | public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId); | ||||
/// <summary> Indicates whether the client has all the members downloaded to the local guild cache. </summary> | /// <summary> Indicates whether the client has all the members downloaded to the local guild cache. </summary> | ||||
public bool HasAllMembers => MemberCount == DownloadedMemberCount;// _downloaderPromise.Task.IsCompleted; | public bool HasAllMembers => MemberCount == DownloadedMemberCount;// _downloaderPromise.Task.IsCompleted; | ||||
@@ -152,7 +167,7 @@ namespace Discord.WebSocket | |||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A <see cref="SocketVoiceChannel" /> that the AFK users will be moved to after they have idled for too | /// A <see cref="SocketVoiceChannel" /> that the AFK users will be moved to after they have idled for too | ||||
/// long; <c>null</c> if none is set. | |||||
/// long; <see langword="null"/> if none is set. | |||||
/// </returns> | /// </returns> | ||||
public SocketVoiceChannel AFKChannel | public SocketVoiceChannel AFKChannel | ||||
{ | { | ||||
@@ -166,8 +181,9 @@ namespace Discord.WebSocket | |||||
/// Gets the embed channel (i.e. the channel set in the guild's widget settings) in this guild. | /// Gets the embed channel (i.e. the channel set in the guild's widget settings) in this guild. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A channel set within the server's widget settings; <c>null</c> if none is set. | |||||
/// A channel set within the server's widget settings; <see langword="null"/> if none is set. | |||||
/// </returns> | /// </returns> | ||||
[Obsolete("This property is deprecated, use WidgetChannel instead.")] | |||||
public SocketGuildChannel EmbedChannel | public SocketGuildChannel EmbedChannel | ||||
{ | { | ||||
get | get | ||||
@@ -177,10 +193,24 @@ namespace Discord.WebSocket | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the widget channel (i.e. the channel set in the guild's widget settings) in this guild. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A channel set within the server's widget settings; <see langword="null"/> if none is set. | |||||
/// </returns> | |||||
public SocketGuildChannel WidgetChannel | |||||
{ | |||||
get | |||||
{ | |||||
var id = WidgetChannelId; | |||||
return id.HasValue ? GetChannel(id.Value) : null; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// Gets the system channel where randomized welcome messages are sent in this guild. | /// Gets the system channel where randomized welcome messages are sent in this guild. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
/// A text channel where randomized welcome messages will be sent to; <c>null</c> if none is set. | |||||
/// A text channel where randomized welcome messages will be sent to; <see langword="null"/> if none is set. | |||||
/// </returns> | /// </returns> | ||||
public SocketTextChannel SystemChannel | public SocketTextChannel SystemChannel | ||||
{ | { | ||||
@@ -191,6 +221,36 @@ namespace Discord.WebSocket | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the channel with the guild rules. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A text channel with the guild rules; <see langword="null"/> if none is set. | |||||
/// </returns> | |||||
public SocketTextChannel RulesChannel | |||||
{ | |||||
get | |||||
{ | |||||
var id = RulesChannelId; | |||||
return id.HasValue ? GetTextChannel(id.Value) : null; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// Gets the channel where admins and moderators of Community guilds receive | |||||
/// notices from Discord. | |||||
/// </summary> | |||||
/// <returns> | |||||
/// A text channel where admins and moderators of Community guilds receive | |||||
/// notices from Discord; <see langword="null"/> if none is set. | |||||
/// </returns> | |||||
public SocketTextChannel PublicUpdatesChannel | |||||
{ | |||||
get | |||||
{ | |||||
var id = PublicUpdatesChannelId; | |||||
return id.HasValue ? GetTextChannel(id.Value) : null; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// Gets a collection of all text channels in this guild. | /// Gets a collection of all text channels in this guild. | ||||
/// </summary> | /// </summary> | ||||
/// <returns> | /// <returns> | ||||
@@ -360,15 +420,24 @@ namespace Discord.WebSocket | |||||
internal void Update(ClientState state, Model model) | internal void Update(ClientState state, Model model) | ||||
{ | { | ||||
AFKChannelId = model.AFKChannelId; | AFKChannelId = model.AFKChannelId; | ||||
EmbedChannelId = model.EmbedChannelId; | |||||
if (model.EmbedChannelId.IsSpecified) | |||||
EmbedChannelId = model.EmbedChannelId.Value; | |||||
if (model.WidgetChannelId.IsSpecified) | |||||
WidgetChannelId = model.WidgetChannelId.Value; | |||||
SystemChannelId = model.SystemChannelId; | SystemChannelId = model.SystemChannelId; | ||||
RulesChannelId = model.RulesChannelId; | |||||
PublicUpdatesChannelId = model.PublicUpdatesChannelId; | |||||
AFKTimeout = model.AFKTimeout; | AFKTimeout = model.AFKTimeout; | ||||
IsEmbeddable = model.EmbedEnabled; | |||||
if (model.EmbedEnabled.IsSpecified) | |||||
IsEmbeddable = model.EmbedEnabled.Value; | |||||
if (model.WidgetEnabled.IsSpecified) | |||||
IsWidgetEnabled = model.WidgetEnabled.Value; | |||||
IconId = model.Icon; | IconId = model.Icon; | ||||
Name = model.Name; | Name = model.Name; | ||||
OwnerId = model.OwnerId; | OwnerId = model.OwnerId; | ||||
VoiceRegionId = model.Region; | VoiceRegionId = model.Region; | ||||
SplashId = model.Splash; | SplashId = model.Splash; | ||||
DiscoverySplashId = model.DiscoverySplash; | |||||
VerificationLevel = model.VerificationLevel; | VerificationLevel = model.VerificationLevel; | ||||
MfaLevel = model.MfaLevel; | MfaLevel = model.MfaLevel; | ||||
DefaultMessageNotifications = model.DefaultMessageNotifications; | DefaultMessageNotifications = model.DefaultMessageNotifications; | ||||
@@ -379,7 +448,14 @@ namespace Discord.WebSocket | |||||
BannerId = model.Banner; | BannerId = model.Banner; | ||||
SystemChannelFlags = model.SystemChannelFlags; | SystemChannelFlags = model.SystemChannelFlags; | ||||
Description = model.Description; | Description = model.Description; | ||||
PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault(); | |||||
if (model.PremiumSubscriptionCount.IsSpecified) | |||||
PremiumSubscriptionCount = model.PremiumSubscriptionCount.Value; | |||||
if (model.MaxPresences.IsSpecified) | |||||
MaxPresences = model.MaxPresences.Value ?? 25000; | |||||
if (model.MaxMembers.IsSpecified) | |||||
MaxMembers = model.MaxMembers.Value; | |||||
if (model.MaxVideoChannelUsers.IsSpecified) | |||||
MaxVideoChannelUsers = model.MaxVideoChannelUsers.Value; | |||||
PreferredLocale = model.PreferredLocale; | PreferredLocale = model.PreferredLocale; | ||||
PreferredCulture = PreferredLocale == null ? null : new CultureInfo(PreferredLocale); | PreferredCulture = PreferredLocale == null ? null : new CultureInfo(PreferredLocale); | ||||
@@ -447,15 +523,20 @@ namespace Discord.WebSocket | |||||
=> GuildHelper.DeleteAsync(this, Discord, options); | => GuildHelper.DeleteAsync(this, Discord, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
public Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null) | ||||
=> GuildHelper.ModifyAsync(this, Discord, func, options); | => GuildHelper.ModifyAsync(this, Discord, func, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
[Obsolete("This endpoint is deprecated, use ModifyWidgetAsync instead.")] | |||||
public Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null) | public Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null) | ||||
=> GuildHelper.ModifyEmbedAsync(this, Discord, func, options); | => GuildHelper.ModifyEmbedAsync(this, Discord, func, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
public Task ModifyWidgetAsync(Action<GuildWidgetProperties> func, RequestOptions options = null) | |||||
=> GuildHelper.ModifyWidgetAsync(this, Discord, func, options); | |||||
/// <inheritdoc /> | |||||
public Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null) | public Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null) | ||||
=> GuildHelper.ReorderChannelsAsync(this, Discord, args, options); | => GuildHelper.ReorderChannelsAsync(this, Discord, args, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
@@ -485,7 +566,7 @@ namespace Discord.WebSocket | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains a ban object, which | /// A task that represents the asynchronous get operation. The task result contains a ban object, which | ||||
/// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | |||||
/// contains the user information and the reason for the ban; <see langword="null"/> if the ban entry cannot be found. | |||||
/// </returns> | /// </returns> | ||||
public Task<RestBan> GetBanAsync(IUser user, RequestOptions options = null) | public Task<RestBan> GetBanAsync(IUser user, RequestOptions options = null) | ||||
=> GuildHelper.GetBanAsync(this, Discord, user.Id, options); | => GuildHelper.GetBanAsync(this, Discord, user.Id, options); | ||||
@@ -496,7 +577,7 @@ namespace Discord.WebSocket | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains a ban object, which | /// A task that represents the asynchronous get operation. The task result contains a ban object, which | ||||
/// contains the user information and the reason for the ban; <c>null</c> if the ban entry cannot be found. | |||||
/// contains the user information and the reason for the ban; <see langword="null"/> if the ban entry cannot be found. | |||||
/// </returns> | /// </returns> | ||||
public Task<RestBan> GetBanAsync(ulong userId, RequestOptions options = null) | public Task<RestBan> GetBanAsync(ulong userId, RequestOptions options = null) | ||||
=> GuildHelper.GetBanAsync(this, Discord, userId, options); | => GuildHelper.GetBanAsync(this, Discord, userId, options); | ||||
@@ -521,7 +602,7 @@ namespace Discord.WebSocket | |||||
/// </summary> | /// </summary> | ||||
/// <param name="id">The snowflake identifier for the channel.</param> | /// <param name="id">The snowflake identifier for the channel.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A generic channel associated with the specified <paramref name="id" />; <c>null</c> if none is found. | |||||
/// A generic channel associated with the specified <paramref name="id" />; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public SocketGuildChannel GetChannel(ulong id) | public SocketGuildChannel GetChannel(ulong id) | ||||
{ | { | ||||
@@ -535,7 +616,7 @@ namespace Discord.WebSocket | |||||
/// </summary> | /// </summary> | ||||
/// <param name="id">The snowflake identifier for the text channel.</param> | /// <param name="id">The snowflake identifier for the text channel.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A text channel associated with the specified <paramref name="id" />; <c>null</c> if none is found. | |||||
/// A text channel associated with the specified <paramref name="id" />; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public SocketTextChannel GetTextChannel(ulong id) | public SocketTextChannel GetTextChannel(ulong id) | ||||
=> GetChannel(id) as SocketTextChannel; | => GetChannel(id) as SocketTextChannel; | ||||
@@ -544,7 +625,7 @@ namespace Discord.WebSocket | |||||
/// </summary> | /// </summary> | ||||
/// <param name="id">The snowflake identifier for the voice channel.</param> | /// <param name="id">The snowflake identifier for the voice channel.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A voice channel associated with the specified <paramref name="id" />; <c>null</c> if none is found. | |||||
/// A voice channel associated with the specified <paramref name="id" />; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public SocketVoiceChannel GetVoiceChannel(ulong id) | public SocketVoiceChannel GetVoiceChannel(ulong id) | ||||
=> GetChannel(id) as SocketVoiceChannel; | => GetChannel(id) as SocketVoiceChannel; | ||||
@@ -553,7 +634,7 @@ namespace Discord.WebSocket | |||||
/// </summary> | /// </summary> | ||||
/// <param name="id">The snowflake identifier for the category channel.</param> | /// <param name="id">The snowflake identifier for the category channel.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A category channel associated with the specified <paramref name="id" />; <c>null</c> if none is found. | |||||
/// A category channel associated with the specified <paramref name="id" />; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public SocketCategoryChannel GetCategoryChannel(ulong id) | public SocketCategoryChannel GetCategoryChannel(ulong id) | ||||
=> GetChannel(id) as SocketCategoryChannel; | => GetChannel(id) as SocketCategoryChannel; | ||||
@@ -589,7 +670,7 @@ namespace Discord.WebSocket | |||||
/// <param name="name">The new name for the voice channel.</param> | /// <param name="name">The new name for the voice channel.</param> | ||||
/// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | ||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <see langword="null"/>.</exception> | |||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous creation operation. The task result contains the newly created | /// A task that represents the asynchronous creation operation. The task result contains the newly created | ||||
/// voice channel. | /// voice channel. | ||||
@@ -602,7 +683,7 @@ namespace Discord.WebSocket | |||||
/// <param name="name">The new name for the category.</param> | /// <param name="name">The new name for the category.</param> | ||||
/// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | /// <param name="func">The delegate containing the properties to be applied to the channel upon its creation.</param> | ||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <see langword="null"/>.</exception> | |||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous creation operation. The task result contains the newly created | /// A task that represents the asynchronous creation operation. The task result contains the newly created | ||||
/// category channel. | /// category channel. | ||||
@@ -666,7 +747,7 @@ namespace Discord.WebSocket | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the partial metadata of | /// A task that represents the asynchronous get operation. The task result contains the partial metadata of | ||||
/// the vanity invite found within this guild; <c>null</c> if none is found. | |||||
/// the vanity invite found within this guild; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public Task<RestInviteMetadata> GetVanityInviteAsync(RequestOptions options = null) | public Task<RestInviteMetadata> GetVanityInviteAsync(RequestOptions options = null) | ||||
=> GuildHelper.GetVanityInviteAsync(this, Discord, options); | => GuildHelper.GetVanityInviteAsync(this, Discord, options); | ||||
@@ -677,7 +758,7 @@ namespace Discord.WebSocket | |||||
/// </summary> | /// </summary> | ||||
/// <param name="id">The snowflake identifier for the role.</param> | /// <param name="id">The snowflake identifier for the role.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A role that is associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// A role that is associated with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public SocketRole GetRole(ulong id) | public SocketRole GetRole(ulong id) | ||||
{ | { | ||||
@@ -699,7 +780,7 @@ namespace Discord.WebSocket | |||||
/// <param name="isHoisted">Whether the role is separated from others on the sidebar.</param> | /// <param name="isHoisted">Whether the role is separated from others on the sidebar.</param> | ||||
/// <param name="isMentionable">Whether the role can be mentioned.</param> | /// <param name="isMentionable">Whether the role can be mentioned.</param> | ||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <see langword="null"/>.</exception> | |||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous creation operation. The task result contains the newly created | /// A task that represents the asynchronous creation operation. The task result contains the newly created | ||||
/// role. | /// role. | ||||
@@ -731,13 +812,13 @@ namespace Discord.WebSocket | |||||
/// <remarks> | /// <remarks> | ||||
/// This method retrieves a user found within this guild. | /// This method retrieves a user found within this guild. | ||||
/// <note> | /// <note> | ||||
/// This may return <c>null</c> in the WebSocket implementation due to incomplete user collection in | |||||
/// This may return <see langword="null"/> in the WebSocket implementation due to incomplete user collection in | |||||
/// large guilds. | /// large guilds. | ||||
/// </note> | /// </note> | ||||
/// </remarks> | /// </remarks> | ||||
/// <param name="id">The snowflake identifier of the user.</param> | /// <param name="id">The snowflake identifier of the user.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A guild user associated with the specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// A guild user associated with the specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public SocketGuildUser GetUser(ulong id) | public SocketGuildUser GetUser(ulong id) | ||||
{ | { | ||||
@@ -891,7 +972,7 @@ namespace Discord.WebSocket | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous get operation. The task result contains the webhook with the | /// A task that represents the asynchronous get operation. The task result contains the webhook with the | ||||
/// specified <paramref name="id"/>; <c>null</c> if none is found. | |||||
/// specified <paramref name="id"/>; <see langword="null"/> if none is found. | |||||
/// </returns> | /// </returns> | ||||
public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) | ||||
=> GuildHelper.GetWebhookAsync(this, Discord, id, options); | => GuildHelper.GetWebhookAsync(this, Discord, id, options); | ||||
@@ -914,7 +995,7 @@ namespace Discord.WebSocket | |||||
public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null) | public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null) | ||||
=> GuildHelper.CreateEmoteAsync(this, Discord, name, image, roles, options); | => GuildHelper.CreateEmoteAsync(this, Discord, name, image, roles, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> | |||||
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception> | |||||
public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null) | public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null) | ||||
=> GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options); | => GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
@@ -1133,11 +1214,21 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
ulong? IGuild.EmbedChannelId => EmbedChannelId; | ulong? IGuild.EmbedChannelId => EmbedChannelId; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
ulong? IGuild.WidgetChannelId => WidgetChannelId; | |||||
/// <inheritdoc /> | |||||
ulong? IGuild.SystemChannelId => SystemChannelId; | ulong? IGuild.SystemChannelId => SystemChannelId; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
ulong? IGuild.RulesChannelId => RulesChannelId; | |||||
/// <inheritdoc /> | |||||
ulong? IGuild.PublicUpdatesChannelId => PublicUpdatesChannelId; | |||||
/// <inheritdoc /> | |||||
IRole IGuild.EveryoneRole => EveryoneRole; | IRole IGuild.EveryoneRole => EveryoneRole; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
IReadOnlyCollection<IRole> IGuild.Roles => Roles; | IReadOnlyCollection<IRole> IGuild.Roles => Roles; | ||||
/// <inheritdoc /> | |||||
int? IGuild.ApproximateMemberCount => null; | |||||
/// <inheritdoc /> | |||||
int? IGuild.ApproximatePresenceCount => null; | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
async Task<IReadOnlyCollection<IBan>> IGuild.GetBansAsync(RequestOptions options) | async Task<IReadOnlyCollection<IBan>> IGuild.GetBansAsync(RequestOptions options) | ||||
@@ -1177,12 +1268,22 @@ namespace Discord.WebSocket | |||||
Task<ITextChannel> IGuild.GetDefaultChannelAsync(CacheMode mode, RequestOptions options) | Task<ITextChannel> IGuild.GetDefaultChannelAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<ITextChannel>(DefaultChannel); | => Task.FromResult<ITextChannel>(DefaultChannel); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
[Obsolete("This method is deprecated, use GetWidgetChannelAsync instead.")] | |||||
Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options) | Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IGuildChannel>(EmbedChannel); | => Task.FromResult<IGuildChannel>(EmbedChannel); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
Task<IGuildChannel> IGuild.GetWidgetChannelAsync(CacheMode mode, RequestOptions options) | |||||
=> Task.FromResult<IGuildChannel>(WidgetChannel); | |||||
/// <inheritdoc /> | |||||
Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options) | Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<ITextChannel>(SystemChannel); | => Task.FromResult<ITextChannel>(SystemChannel); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
Task<ITextChannel> IGuild.GetRulesChannelAsync(CacheMode mode, RequestOptions options) | |||||
=> Task.FromResult<ITextChannel>(RulesChannel); | |||||
/// <inheritdoc /> | |||||
Task<ITextChannel> IGuild.GetPublicUpdatesChannelAsync(CacheMode mode, RequestOptions options) | |||||
=> Task.FromResult<ITextChannel>(PublicUpdatesChannel); | |||||
/// <inheritdoc /> | |||||
async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, Action<TextChannelProperties> func, RequestOptions options) | async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, Action<TextChannelProperties> func, RequestOptions options) | ||||
=> await CreateTextChannelAsync(name, func, options).ConfigureAwait(false); | => await CreateTextChannelAsync(name, func, options).ConfigureAwait(false); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||