Browse Source

Add information for DiscordSocketConfig

+ Add remarks/example to the class
+ Add remarks to AlwaysDownloadUsers
pull/1218/head
Still Hsu 7 years ago
parent
commit
29e8cc71c3
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
1 changed files with 40 additions and 0 deletions
  1. +40
    -0
      src/Discord.Net.WebSocket/DiscordSocketConfig.cs

+ 40
- 0
src/Discord.Net.WebSocket/DiscordSocketConfig.cs View File

@@ -7,6 +7,22 @@ namespace Discord.WebSocket
/// <summary> /// <summary>
/// Represents a configuration class for <see cref="DiscordSocketClient"/>. /// Represents a configuration class for <see cref="DiscordSocketClient"/>.
/// </summary> /// </summary>
/// <remarks>
/// This configuration, based on <see cref="DiscordRestConfig"/>, helps determine several key configurations the
/// socket client depend on. For instance, shards and connection timeout.
/// </remarks>
/// <example>
/// The following config enables the message cache and configures the client to always download user upon guild
/// availability.
/// <code language="cs">
/// var config = new DiscordSocketConfig
/// {
/// AlwaysDownloadUsers = true,
/// MessageCacheSize = 100
/// };
/// var client = new DiscordSocketClient(config);
/// </code>
/// </example>
public class DiscordSocketConfig : DiscordRestConfig public class DiscordSocketConfig : DiscordRestConfig
{ {
/// <summary> /// <summary>
@@ -57,6 +73,30 @@ namespace Discord.WebSocket
/// <summary> /// <summary>
/// Gets or sets whether or not all users should be downloaded as guilds come available. /// Gets or sets whether or not all users should be downloaded as guilds come available.
/// </summary> /// </summary>
/// <remarks>
/// <para>
/// By default, Discord gateway will only send offline members if a guild has less than a certain number
/// of members (determined by <see cref="LargeThreshold"/> in this library). This behaviour is why
/// sometimes a user may be missing from the WebSocket cache for collections such as
/// <see cref="Discord.WebSocket.SocketGuild.Users"/>.
/// </para>
/// <para>
/// This property ensures that whenever a guild becomes available (determined by
/// <see cref="Discord.WebSocket.BaseSocketClient.GuildAvailable"/>), incomplete user chunks will be
/// downloaded to the WebSocket cache.
/// </para>
/// <para>
/// For more information, please see
/// <see href="https://discordapp.com/developers/docs/topics/gateway#request-guild-members">Request Guild Members</see>
/// on the official Discord API documentation.
/// </para>
/// <note>
/// Please note that it can be difficult to fill the cache completely on large guilds depending on the
/// traffic. If you are using the command system, the default user TypeReader may fail to find the user
/// due to this issue. This may be resolved at v3 of the library. Until then, you may want to consider
/// overriding the TypeReader and use <see cref="DiscordRestClient.GetGuildUserAsync"/> as a backup.
/// </note>
/// </remarks>
public bool AlwaysDownloadUsers { get; set; } = false; public bool AlwaysDownloadUsers { get; set; } = false;
/// <summary> /// <summary>
/// Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. Null /// Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. Null


Loading…
Cancel
Save