/// <summary> /// Creates a new LavalinkNode instance without a Cluster /// </summary> /// <param name="options">The options of this Node</param> /// <param name="discordSendFunction">The DiscordSendFunction for the OP4 Packets</param> /// <param name="client">Optional, the HttpClient to use for Rest Requests</param> public LavalinkNode(LavalinkNodeOptions options, Func <long, UpdateVoiceStateDispatch, Task> discordSendFunction, HttpClient client = null) { Options = options; ResumeKey = options.ResumeKey; Players = new PlayerStore(this); _discordSendFunction = discordSendFunction; _http = client ?? new HttpClient(); }
/// <summary> /// Creates a new LavalinkNode instance from a Cluster /// </summary> /// <param name="cluster">The LavalinkCluster which this Node is a part of</param> /// <param name="options">The options of this Node</param> public LavalinkNode(LavalinkCluster cluster, LavalinkNodeOptions options) { Cluster = cluster; Event += (sender, data) => Cluster.EmitEvent(EventType.EVENT, data); Stats += (sender, data) => Cluster.EmitEvent(EventType.STATS, data); Logs += (sender, data) => Cluster.EmitEvent(EventType.LOGS, data); Players = new PlayerStore(this); Options = options; ResumeKey = options.ResumeKey; }
/// <summary> /// Creates a new Client instance. /// </summary> /// <param name="options"> Options to instance the Client with. </param> public Client(ClientOptions options) { _config = options; Websocket = new Websocket.Websocket(new WebsocketOptions(_config.HostWS, _config.Password, _config.UserID, _config.ShardCount)); Players = new PlayerStore(this); if (options.UseLogging) { Logger = new LoggerConfiguration().MinimumLevel.ControlledBy(new Serilog.Core.LoggingLevelSwitch((Serilog.Events.LogEventLevel)_config.LogLevel)).WriteTo.Console().CreateLogger(); } Websocket.Message += WebsocketMessage; Websocket.Ready += ReadyHandler; Websocket.Debug += DebugHandler; Websocket.Close += DisconnectHandler; Websocket.ConnectionFailed += ConnectionFailedHandler; }