The FluxerConfig class controls the behavior of both the ApiClient and GatewayClient. This guide covers all configuration options and their usage.
var config = new FluxerConfig
{
// Default values shown
ReconnectAttemptDelay = 10,
FluxerApiBaseUrl = "https://api.fluxer.app/v{v}",
Version = 1,
FluxerGatewayUrl = "wss://gateway.fluxer.app/?v=1&encoding=json",
EnableRateLimiting = true
};
Type: int
Default: 10 seconds
Number of seconds to wait between gateway reconnection attempts. This prevents rapid reconnection attempts that could trigger rate limits.
var config = new FluxerConfig
{
ReconnectAttemptDelay = 5 // Reconnect every 5 seconds
};
Type: Serilog.Core.Logger?
Default: null
Custom Serilog logger configuration. If null, the library creates a default console logger. Allows you to separate Fluxer.Net logs from your application logs or customize the output format.
using Serilog;
var fluxerLogger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.File("logs/fluxer-.txt", rollingInterval: RollingInterval.Day)
.WriteTo.Console()
.CreateLogger();
var config = new FluxerConfig
{
Serilog = fluxerLogger
};
Type: string
Default: "https://api.fluxer.app/v{v}"
Base URL for the Fluxer REST API. The {v} placeholder is replaced with the Version property value. You typically don't need to change this unless you're using a proxy or testing with a local Fluxer instance.
var config = new FluxerConfig
{
FluxerApiBaseUrl = "https://my-proxy.example.com/fluxer/v{v}"
};
Type: int
Default: 1
API version number. Currently, only version 1 is supported by Fluxer.
Type: string
Default: "wss://gateway.fluxer.app/?v=1&encoding=json"
WebSocket gateway URL for real-time events. Must use JSON encoding (compression is not currently supported).
var config = new FluxerConfig
{
FluxerGatewayUrl = "wss://my-gateway.example.com/?v=1&encoding=json"
};
Type: HttpClient?
Default: null
Optional HttpClient instance for API requests. If null, a new HttpClient is created automatically. Providing your own allows for:
var httpClient = new HttpClient
{
Timeout = TimeSpan.FromSeconds(30)
};
// Configure proxy
var handler = new HttpClientHandler
{
Proxy = new WebProxy("http://proxy.example.com:8080"),
UseProxy = true
};
var httpClient = new HttpClient(handler);
var config = new FluxerConfig
{
HttpClient = httpClient
};
Type: List<string>
Default: new List<string>() (empty)
List of gateway event dispatch types to ignore. Useful for filtering out high-volume events your application doesn't need, which can reduce bandwidth and CPU usage.
var config = new FluxerConfig
{
IgnoredGatewayEvents = new List
{
"PRESENCE_UPDATE", // Don't receive presence updates
"TYPING_START", // Don't receive typing indicators
"TYPING_STOP", // Don't receive typing stop events
"MESSAGE_REACTION_ADD" // Don't receive reaction events
}
};
Available events to ignore:
PRESENCE_UPDATE - User status changesTYPING_START / TYPING_STOP - Typing indicatorsMESSAGE_REACTION_ADD / MESSAGE_REACTION_REMOVE - Message reactionsVOICE_STATE_UPDATE - Voice channel changesUSER_SETTINGS_UPDATE - User settings changesType: PresenceUpdateGatewayData?
Default: null
Initial presence data to send when connecting to the gateway. Sets your bot's or user's online status and activity.
using Fluxer.Net.Data.Enums;
using Fluxer.Net.Gateway.Data;
var config = new FluxerConfig
{
Presence = new PresenceUpdateGatewayData(Status.DoNotDisturb)
{
// Custom status can be set here if supported
}
};
Available status values:
Status.Online - Green (Online)Status.Idle - Yellow (Away)Status.DoNotDisturb - Red (Do Not Disturb)Status.Invisible - Gray (Appear Offline)Type: bool
Default: true
Enable client-side rate limiting using a sliding window algorithm. When enabled, API requests automatically wait when approaching rate limits to prevent HTTP 429 responses from the server.
var config = new FluxerConfig
{
EnableRateLimiting = true // Recommended for production
};
Important: Disabling rate limiting is not recommended for production bots, as it can lead to your bot being temporarily or permanently banned for exceeding rate limits.
using Fluxer.Net;
using Fluxer.Net.Data.Enums;
using Fluxer.Net.Gateway.Data;
using Serilog;
// Configure custom logger
var logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Console()
.WriteTo.File(
path: "logs/fluxer-.txt",
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: 7
)
.CreateLogger();
// Configure HTTP client with custom settings
var httpClient = new HttpClient
{
Timeout = TimeSpan.FromSeconds(30)
};
// Create comprehensive configuration
var config = new FluxerConfig
{
// Logging
Serilog = logger,
// Network configuration
HttpClient = httpClient,
ReconnectAttemptDelay = 10,
// Rate limiting
EnableRateLimiting = true,
// Gateway event filtering
IgnoredGatewayEvents = new List
{
"PRESENCE_UPDATE",
"TYPING_START",
"TYPING_STOP"
},
// Initial presence
Presence = new PresenceUpdateGatewayData(Status.Online)
};
// Initialize clients with configuration
const string token = "YOUR_TOKEN_HERE";
var apiClient = new ApiClient(token, config);
var gatewayClient = new GatewayClient(token, config);
It's common to use different configurations for development and production:
var isDevelopment = Environment.GetEnvironmentVariable("ENVIRONMENT") == "Development";
var config = new FluxerConfig
{
Serilog = new LoggerConfiguration()
.MinimumLevel.Is(isDevelopment ? LogEventLevel.Debug : LogEventLevel.Information)
.WriteTo.Console()
.CreateLogger(),
ReconnectAttemptDelay = isDevelopment ? 5 : 10,
IgnoredGatewayEvents = isDevelopment
? new List() // Receive all events in development
: new List { "PRESENCE_UPDATE", "TYPING_START" } // Filter in production
};
Store configuration in appsettings.json or environment variables:
{
"Fluxer": {
"Token": "YOUR_TOKEN_HERE",
"Prefix": "!",
"ReconnectDelay": 10,
"IgnoredEvents": ["PRESENCE_UPDATE", "TYPING_START"]
}
}
// Bad: Hardcoded token
const string token = "real_token_here";
// Good: Load from environment
var token = Environment.GetEnvironmentVariable("FLUXER_TOKEN")
?? throw new Exception("FLUXER_TOKEN environment variable not set");
If you create multiple ApiClient instances, share the same HttpClient to enable connection pooling:
var sharedHttpClient = new HttpClient();
var config1 = new FluxerConfig { HttpClient = sharedHttpClient };
var config2 = new FluxerConfig { HttpClient = sharedHttpClient };
var apiClient1 = new ApiClient(token1, config1);
var apiClient2 = new ApiClient(token2, config2);
Configure appropriate log levels for your environment and monitor for errors or warnings.