LavalinkGuildConnection.IsConnected is true even if the channel is null.
Created by: Kriste00
Details
LavalinkGuildConnection.IsConnected
will return true even if the channel its connected to is null. Also GetConnection(gld)
will return a connection without a channel and say its connected.
Example code that can get the nullref:
var vnc = GetConnection(gld);
if (vnc?.IsConnected != true)
return;
vnc.Play("...");
---------------------------------------------
System.NullReferenceException: Object reference not set to an instance of an object.
at DSharpPlus.Lavalink.LavalinkGuildConnection.get_GuildId()
at DSharpPlus.Lavalink.LavalinkGuildConnection.get_GuildIdString()
at DSharpPlus.Lavalink.LavalinkGuildConnection.Play(LavalinkTrack track)
https://github.com/DSharpPlus/DSharpPlus/blob/fa925ceac997d0af369c745c75d991b97dae54f3/DSharpPlus.Lavalink/LavalinkGuildConnection.cs#L74
This line could be changed to public bool IsConnected => !Volatile.Read(ref this._isDisposed) && this.Channel != null;
and make GetConnection
return null if the channel on the connection is null.
Steps to reproduce
I dont really know how to reproduce it, let the bot run for a couble of days i guess.