public async Task <string> PlayQuery(SocketUser username, IGuild guild, IVoiceChannel voiceChannel, ITextChannel textChannel, string query) { try { var search = Uri.IsWellFormedUriString(query, UriKind.Absolute) ? await lavaNode.SearchAsync(Victoria.Responses.Search.SearchType.Direct, query) : await lavaNode.SearchAsync(Victoria.Responses.Search.SearchType.YouTube, query); if (search.Status == Victoria.Responses.Search.SearchStatus.LoadFailed) { return($"Sorry, failed to load query."); } LavaTrack track = null; track = search.Tracks.FirstOrDefault(); if (track == null) { return("Sorry, can't find the track."); } var player = lavaNode.HasPlayer(guild) ? lavaNode.GetPlayer(guild) : await lavaNode.JoinAsync(voiceChannel, textChannel); if (!guildInfo.TryGetValue(guild, out var g)) { guildInfo.TryAdd(guild, new DJGuildInfo(voiceChannel)); } DJGuildInfo currentGuild = null; guildInfo.TryGetValue(guild, out currentGuild); currentGuild.Enqueue(username, track); if (player.PlayerState == Victoria.Enums.PlayerState.Playing) { return($"**Enqueued** `{track.Title}`"); } else { currentGuild.PlayNext(); await player.PlayAsync(currentGuild.currentlyPlaying.track); return($"**Playing** 🎶 `{track.Title}`"); } }catch (Exception e) { return($"Error playing query: `{e.Message}`."); } }