private async Task PlayHandlerAsync() { var itemN = this.Dequeue(); if (itemN == null) { await Task.Delay(500); await DestroyPlayerAsync(); return; } var item = itemN.Value; this.NowPlaying = item; this.IsPlaying = true; await this.Player.PlayAsync(item.Track); if (IsMeme) { return; } var builder = new DiscordEmbedBuilder(); builder.Color = CommandChannel.Guild.CurrentMember.Color; builder.AddField("Now Playing:", item.Track.Title, true); builder.AddField("Queued By:", item.RequestedBy.Mention, true); builder.AddField("URL:", item.Track.Uri.ToString(), false); builder.WithThumbnail(item.RequestedBy.AvatarUrl); await CommandChannel.SendMessageAsync(embed : builder.Build()); }
public async Task DestroyPlayerAsync() { if (this.Player == null) { return; } if (this.Player.IsConnected) { await this.Player.DisconnectAsync(); } this.Player = null; this.Host = null; await CommandChannel.SendMessageAsync($"The previously active music session has been terminated"); this.CommandChannel = null; }
public async Task <bool> CreatePlayerAsync(DiscordChannel channel) { if (this.Player != null && this.Player.IsConnected) { return(false); } this.Player = await this.Lavalink.LavalinkNode.ConnectAsync(channel); if (this.Volume != 100) { await this.Player.SetVolumeAsync(this.Volume); } this.Player.PlaybackFinished += this.PlaybackFinished; await CommandChannel.SendMessageAsync($"A music session has started in {channel.Name}!"); return(true); }