Search Results for

    Show / Hide Table of Contents

    Class DiscordSocketConfig

    Represents a configuration class for DiscordSocketClient.

    Inheritance
    Object
    DiscordConfig
    DiscordRestConfig
    DiscordSocketConfig
    Inherited Members
    DiscordRestConfig.RestClientProvider
    DiscordConfig.APIVersion
    DiscordConfig.VoiceAPIVersion
    DiscordConfig.Version
    DiscordConfig.UserAgent
    DiscordConfig.APIUrl
    DiscordConfig.CDNUrl
    DiscordConfig.InviteUrl
    DiscordConfig.DefaultRequestTimeout
    DiscordConfig.MaxMessageSize
    DiscordConfig.MaxMessagesPerBatch
    DiscordConfig.MaxUsersPerBatch
    DiscordConfig.MaxBansPerBatch
    DiscordConfig.MaxGuildEventUsersPerBatch
    DiscordConfig.MaxGuildsPerBatch
    DiscordConfig.MaxUserReactionsPerBatch
    DiscordConfig.MaxAuditLogEntriesPerBatch
    DiscordConfig.DefaultRetryMode
    DiscordConfig.DefaultRatelimitCallback
    DiscordConfig.LogLevel
    DiscordConfig.UseSystemClock
    DiscordConfig.UseInteractionSnowflakeDate
    DiscordConfig.FormatUsersInBidirectionalUnicode
    Namespace: Discord.WebSocket
    Assembly: Discord.Net.WebSocket.dll
    Syntax
    public class DiscordSocketConfig : DiscordRestConfig
    Remarks

    This configuration, based on DiscordRestConfig, helps determine several key configurations the socket client depend on. For instance, shards and connection timeout.

    Examples

    The following config enables the message cache and configures the client to always download user upon guild availability.

    var config = new DiscordSocketConfig
    {
        AlwaysDownloadUsers = true,
        MessageCacheSize = 100
    };
    var client = new DiscordSocketClient(config);

    Constructors

    | Improve this Doc View Source

    DiscordSocketConfig()

    Initializes a new instance of the DiscordSocketConfig class with the default configuration.

    Declaration
    public DiscordSocketConfig()

    Fields

    | Improve this Doc View Source

    GatewayEncoding

    Returns the encoding gateway should use.

    Declaration
    public const string GatewayEncoding = null
    Field Value
    Type Description
    String

    Properties

    | Improve this Doc View Source

    AlwaysDownloadDefaultStickers

    Gets or sets whether or not the client should download the default stickers on startup.

    Declaration
    public bool AlwaysDownloadDefaultStickers { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    When this is set to false default stickers arn't present and cannot be resolved by the client. This will make all default stickers have the type of SocketUnknownSticker.

    | Improve this Doc View Source

    AlwaysDownloadUsers

    Gets or sets whether or not all users should be downloaded as guilds come available.

    Declaration
    public bool AlwaysDownloadUsers { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    By default, the Discord gateway will only send offline members if a guild has less than a certain number of members (determined by LargeThreshold in this library). This behavior is why sometimes a user may be missing from the WebSocket cache for collections such as Users.

    This property ensures that whenever a guild becomes available (determined by GuildAvailable), incomplete user chunks will be downloaded to the WebSocket cache.

    For more information, please see Request Guild Members on the official Discord API documentation.

    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 GetUserAsync(UInt64, RequestOptions) or GetGuildUserAsync(UInt64, UInt64, RequestOptions) as a backup.

    | Improve this Doc View Source

    AlwaysResolveStickers

    Gets or sets whether or not the client should automatically resolve the stickers sent on a message.

    Declaration
    public bool AlwaysResolveStickers { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    Note if a sticker isn't cached the client will preform a rest request to resolve it. This may be very rest heavy depending on your bots size, it isn't recommended to use this with large scale bots as you can get ratelimited easily.

    | Improve this Doc View Source

    ConnectionTimeout

    Gets or sets the time, in milliseconds, to wait for a connection to complete before aborting.

    Declaration
    public int ConnectionTimeout { get; set; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    GatewayHost

    Gets or sets the WebSocket host to connect to. If null, the client will use the /gateway endpoint.

    Declaration
    public string GatewayHost { get; set; }
    Property Value
    Type Description
    String
    | Improve this Doc View Source

    GatewayIntents

    Gets or sets gateway intents to limit what events are sent from Discord. The default is AllUnprivileged.

    Declaration
    public GatewayIntents GatewayIntents { get; set; }
    Property Value
    Type Description
    GatewayIntents
    Remarks

    For more information, please see GatewayIntents on the official Discord API documentation.

    | Improve this Doc View Source

    HandlerTimeout

    Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. Setting this property to nulldisables this check.

    Declaration
    public int? HandlerTimeout { get; set; }
    Property Value
    Type Description
    Nullable<Int32>
    | Improve this Doc View Source

    IdentifyMaxConcurrency

    Gets or sets the maximum identify concurrency.

    Declaration
    public int IdentifyMaxConcurrency { get; set; }
    Property Value
    Type Description
    Int32
    Remarks

    This information is provided by Discord. It is only used when using a DiscordShardedClient and auto-sharding is disabled.

    | Improve this Doc View Source

    LargeThreshold

    Gets or sets the max number of users a guild may have for offline users to be included in the READY packet. The maximum value allowed is 250.

    Declaration
    public int LargeThreshold { get; set; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    LogGatewayIntentWarnings

    Gets or sets whether or not to log warnings related to guild intents and events.

    Declaration
    public bool LogGatewayIntentWarnings { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    MaxWaitBetweenGuildAvailablesBeforeReady

    Gets or sets the maximum wait time in milliseconds between GUILD_AVAILABLE events before firing READY. If zero, READY will fire as soon as it is received and all guilds will be unavailable.

    Declaration
    public int MaxWaitBetweenGuildAvailablesBeforeReady { get; set; }
    Property Value
    Type Description
    Int32

    A representing the maximum wait time in milliseconds between GUILD_AVAILABLE events before firing READY.

    Remarks

    This property is measured in milliseconds; negative values will throw an exception.

    If a guild is not received before READY, it will be unavailable.

    | Improve this Doc View Source

    MessageCacheSize

    Gets or sets the number of messages per channel that should be kept in cache. Setting this to zero disables the message cache entirely.

    Declaration
    public int MessageCacheSize { get; set; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    ShardId

    Gets or sets the ID for this shard. Must be less than TotalShards.

    Declaration
    public int? ShardId { get; set; }
    Property Value
    Type Description
    Nullable<Int32>
    | Improve this Doc View Source

    SuppressUnknownDispatchWarnings

    Gets or sets whether or not Unknown Dispatch event messages should be logged.

    Declaration
    public bool SuppressUnknownDispatchWarnings { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    TotalShards

    Gets or sets the total number of shards for this application.

    Declaration
    public int? TotalShards { get; set; }
    Property Value
    Type Description
    Nullable<Int32>
    Remarks

    If this is left null in a sharded client the bot will get the recommended shard count from discord and use that.

    | Improve this Doc View Source

    UdpSocketProvider

    Gets or sets the provider used to generate new UDP sockets.

    Declaration
    public UdpSocketProvider UdpSocketProvider { get; set; }
    Property Value
    Type Description
    Discord.Net.Udp.UdpSocketProvider
    | Improve this Doc View Source

    WebSocketProvider

    Gets or sets the provider used to generate new WebSocket connections.

    Declaration
    public WebSocketProvider WebSocketProvider { get; set; }
    Property Value
    Type Description
    Discord.Net.WebSockets.WebSocketProvider

    Theme

    • Improve this Doc
    • View Source
    In This Article
    Back to top Discord.Net (c) 2015-2022 3.6.0