mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
- removed unused attributes on commands
- Removed some commented out files
This commit is contained in:
@@ -1,717 +0,0 @@
|
||||
// using Discord;
|
||||
// using Discord.Audio;
|
||||
// using System;
|
||||
// using System.Threading;
|
||||
// using System.Threading.Tasks;
|
||||
// using System.Linq;
|
||||
// using System.Runtime.InteropServices;
|
||||
// using NadekoBot.Extensions;
|
||||
// using NadekoBot.Common.Collections;
|
||||
// using NadekoBot.Modules.Music.Services;
|
||||
// using NadekoBot.Services;
|
||||
// using NadekoBot.Services.Database.Models;
|
||||
// using Discord.WebSocket;
|
||||
// using Serilog;
|
||||
//
|
||||
// namespace NadekoBot.Modules.Music.Common
|
||||
// {
|
||||
// public enum StreamState
|
||||
// {
|
||||
// Resolving,
|
||||
// Queued,
|
||||
// Playing,
|
||||
// Completed
|
||||
// }
|
||||
// public class MusicPlayer
|
||||
// {
|
||||
// private readonly Thread _player;
|
||||
// public IVoiceChannel VoiceChannel { get; private set; }
|
||||
//
|
||||
// public ITextChannel OriginalTextChannel { get; set; }
|
||||
//
|
||||
// private MusicQueue Queue { get; } = new MusicQueue();
|
||||
//
|
||||
// public bool Exited { get; set; } = false;
|
||||
// public bool Stopped { get; private set; } = false;
|
||||
// public float Volume { get; private set; } = 1.0f;
|
||||
// public bool Paused => PauseTaskSource != null;
|
||||
// private TaskCompletionSource<bool> PauseTaskSource { get; set; } = null;
|
||||
//
|
||||
// public string PrettyVolume => $"🔉 {(int)(Volume * 100)}%";
|
||||
// public string PrettyCurrentTime
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// var time = CurrentTime.ToString(@"mm\:ss");
|
||||
// var hrs = (int)CurrentTime.TotalHours;
|
||||
//
|
||||
// if (hrs > 0)
|
||||
// return hrs + ":" + time;
|
||||
// else
|
||||
// return time;
|
||||
// }
|
||||
// }
|
||||
// public string PrettyFullTime => PrettyCurrentTime + " / " + (Queue.Current.Song?.PrettyTotalTime ?? "?");
|
||||
// private CancellationTokenSource SongCancelSource { get; set; }
|
||||
// public ITextChannel OutputTextChannel { get; set; }
|
||||
// public (int Index, SongInfo Current) Current
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (Stopped)
|
||||
// return (0, null);
|
||||
// return Queue.Current;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public bool RepeatCurrentSong { get; private set; }
|
||||
// public bool Shuffle { get; private set; }
|
||||
// public bool Autoplay { get; private set; }
|
||||
// public bool RepeatPlaylist { get; private set; } = false;
|
||||
// public uint MaxQueueSize
|
||||
// {
|
||||
// get => Queue.MaxQueueSize;
|
||||
// set { lock (locker) Queue.MaxQueueSize = value; }
|
||||
// }
|
||||
// private bool _fairPlay;
|
||||
// public bool FairPlay
|
||||
// {
|
||||
// get => _fairPlay;
|
||||
// set
|
||||
// {
|
||||
// if (value)
|
||||
// {
|
||||
// var (Index, Song) = Queue.Current;
|
||||
// if (Song != null)
|
||||
// RecentlyPlayedUsers.Add(Song.QueuerName);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// RecentlyPlayedUsers.Clear();
|
||||
// }
|
||||
//
|
||||
// _fairPlay = value;
|
||||
// }
|
||||
// }
|
||||
// public bool AutoDelete { get; set; }
|
||||
// public uint MaxPlaytimeSeconds { get; set; }
|
||||
//
|
||||
//
|
||||
// const int _frameBytes = 3840;
|
||||
// const float _miliseconds = 20.0f;
|
||||
// public TimeSpan CurrentTime => TimeSpan.FromSeconds(_bytesSent / (float)_frameBytes / (1000 / _miliseconds));
|
||||
//
|
||||
// private int _bytesSent = 0;
|
||||
//
|
||||
// private IAudioClient _audioClient;
|
||||
// private readonly object locker = new object();
|
||||
// private MusicService _musicService;
|
||||
//
|
||||
// #region events
|
||||
// public event Action<MusicPlayer, (int Index, SongInfo Song)> OnStarted;
|
||||
// public event Action<MusicPlayer, SongInfo> OnCompleted;
|
||||
// public event Action<MusicPlayer, bool> OnPauseChanged;
|
||||
// #endregion
|
||||
//
|
||||
// private bool manualSkip = false;
|
||||
// private bool manualIndex = false;
|
||||
// private bool newVoiceChannel = false;
|
||||
// private readonly IGoogleApiService _google;
|
||||
//
|
||||
// private bool cancel = false;
|
||||
//
|
||||
// private ConcurrentHashSet<string> RecentlyPlayedUsers { get; } = new ConcurrentHashSet<string>();
|
||||
// public TimeSpan TotalPlaytime
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// var songs = Queue.ToArray().Songs;
|
||||
// return songs.Any(s => s.TotalTime == TimeSpan.MaxValue)
|
||||
// ? TimeSpan.MaxValue
|
||||
// : new TimeSpan(songs.Sum(s => s.TotalTime.Ticks));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public MusicPlayer(MusicService musicService, MusicSettings ms, IGoogleApiService google,
|
||||
// IVoiceChannel vch, ITextChannel original, float volume)
|
||||
// {
|
||||
// this.Volume = volume;
|
||||
// this.VoiceChannel = vch;
|
||||
// this.OriginalTextChannel = original;
|
||||
// this.SongCancelSource = new CancellationTokenSource();
|
||||
// if (ms.MusicChannelId is ulong cid)
|
||||
// {
|
||||
// this.OutputTextChannel = ((SocketGuild)original.Guild).GetTextChannel(cid) ?? original;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// this.OutputTextChannel = original;
|
||||
// }
|
||||
// this._musicService = musicService;
|
||||
// this.AutoDelete = ms.SongAutoDelete;
|
||||
// this._google = google;
|
||||
//
|
||||
// _player = new Thread(new ThreadStart(PlayerLoop))
|
||||
// {
|
||||
// Priority = ThreadPriority.AboveNormal
|
||||
// };
|
||||
// _player.Start();
|
||||
// }
|
||||
//
|
||||
// private async void PlayerLoop()
|
||||
// {
|
||||
// while (!Exited)
|
||||
// {
|
||||
// _bytesSent = 0;
|
||||
// cancel = false;
|
||||
// CancellationToken cancelToken;
|
||||
// (int Index, SongInfo Song) data;
|
||||
// lock (locker)
|
||||
// {
|
||||
// data = Queue.Current;
|
||||
// cancelToken = SongCancelSource.Token;
|
||||
// manualSkip = false;
|
||||
// manualIndex = false;
|
||||
// }
|
||||
// if (data.Song != null)
|
||||
// {
|
||||
// Log.Information("Starting");
|
||||
// AudioOutStream pcm = null;
|
||||
// SongBuffer b = null;
|
||||
// try
|
||||
// {
|
||||
// var streamUrl = await data.Song.Uri().ConfigureAwait(false);
|
||||
// b = new SongBuffer(streamUrl, data.Song.ProviderType == MusicType.Local);
|
||||
// //Log.Information("Created buffer, buffering...");
|
||||
//
|
||||
// //var bufferTask = b.StartBuffering(cancelToken);
|
||||
// //var timeout = Task.Delay(10000);
|
||||
// //if (Task.WhenAny(bufferTask, timeout) == timeout)
|
||||
// //{
|
||||
// // Log.Information("Buffering failed due to a timeout.");
|
||||
// // continue;
|
||||
// //}
|
||||
// //else if (!bufferTask.Result)
|
||||
// //{
|
||||
// // Log.Information("Buffering failed due to a cancel or error.");
|
||||
// // continue;
|
||||
// //}
|
||||
// //Log.Information("Buffered. Getting audio client...");
|
||||
// var ac = await GetAudioClient().ConfigureAwait(false);
|
||||
// Log.Information("Got Audio client");
|
||||
// if (ac is null)
|
||||
// {
|
||||
// Log.Information("Can't join");
|
||||
// await Task.Delay(900, cancelToken).ConfigureAwait(false);
|
||||
// // just wait some time, maybe bot doesn't even have perms to join that voice channel,
|
||||
// // i don't want to spam connection attempts
|
||||
// continue;
|
||||
// }
|
||||
// b.StartBuffering();
|
||||
// await Task.WhenAny(Task.Delay(10000), b.PrebufferingCompleted.Task).ConfigureAwait(false);
|
||||
// pcm = ac.CreatePCMStream(AudioApplication.Music, bufferMillis: 1, packetLoss: 5);
|
||||
// Log.Information("Created pcm stream");
|
||||
// OnStarted?.Invoke(this, data);
|
||||
//
|
||||
// while (MaxPlaytimeSeconds <= 0 || MaxPlaytimeSeconds >= CurrentTime.TotalSeconds)
|
||||
// {
|
||||
// var buffer = b.Read(3840);
|
||||
// if (buffer.Length == 0)
|
||||
// break;
|
||||
// AdjustVolume(buffer, Volume);
|
||||
// await pcm.WriteAsync(buffer, 0, buffer.Length, cancelToken).ConfigureAwait(false);
|
||||
// unchecked { _bytesSent += buffer.Length; }
|
||||
//
|
||||
// await (PauseTaskSource?.Task ?? Task.CompletedTask).ConfigureAwait(false);
|
||||
// }
|
||||
// }
|
||||
// catch (OperationCanceledException)
|
||||
// {
|
||||
// Log.Information("Song Canceled");
|
||||
// cancel = true;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Log.Warning(ex, "Error sending song data");
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// if (pcm != null)
|
||||
// {
|
||||
// // flush is known to get stuck from time to time,
|
||||
// // just skip flushing if it takes more than 1 second
|
||||
// var flushCancel = new CancellationTokenSource();
|
||||
// var flushToken = flushCancel.Token;
|
||||
// var flushDelay = Task.Delay(1000, flushToken);
|
||||
// await Task.WhenAny(flushDelay, pcm.FlushAsync(flushToken)).ConfigureAwait(false);
|
||||
// flushCancel.Cancel();
|
||||
// pcm.Dispose();
|
||||
// }
|
||||
//
|
||||
// if (b != null)
|
||||
// b.Dispose();
|
||||
//
|
||||
// OnCompleted?.Invoke(this, data.Song);
|
||||
//
|
||||
// if (_bytesSent == 0 && !cancel)
|
||||
// {
|
||||
// lock (locker)
|
||||
// Queue.RemoveSong(data.Song);
|
||||
// Log.Information("Song removed because it can't play");
|
||||
// }
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// //if repeating current song, just ignore other settings,
|
||||
// // and play this song again (don't change the index)
|
||||
// // ignore rcs if song is manually skipped
|
||||
//
|
||||
// int queueCount;
|
||||
// bool stopped;
|
||||
// int currentIndex;
|
||||
// lock (locker)
|
||||
// {
|
||||
// queueCount = Queue.Count;
|
||||
// stopped = Stopped;
|
||||
// currentIndex = Queue.CurrentIndex;
|
||||
// }
|
||||
//
|
||||
// if (AutoDelete && !RepeatCurrentSong && !RepeatPlaylist && data.Song != null)
|
||||
// {
|
||||
// Queue.RemoveSong(data.Song);
|
||||
// }
|
||||
//
|
||||
// if (!manualIndex && (!RepeatCurrentSong || manualSkip))
|
||||
// {
|
||||
// if (Shuffle)
|
||||
// {
|
||||
// Log.Information("Random song");
|
||||
// Queue.Random(); //if shuffle is set, set current song index to a random number
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //if last song, and autoplay is enabled, and if it's a youtube song
|
||||
// // do autplay magix
|
||||
// if (queueCount - 1 == data.Index && Autoplay && data.Song?.ProviderType == MusicType.YouTube)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Log.Information("Loading related song");
|
||||
// await _musicService.TryQueueRelatedSongAsync(data.Song, OutputTextChannel, VoiceChannel).ConfigureAwait(false);
|
||||
// if (!AutoDelete)
|
||||
// Queue.Next();
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// Log.Information("Loading related song failed");
|
||||
// }
|
||||
// }
|
||||
// else if (FairPlay)
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// Log.Information("Next fair song");
|
||||
// var queueList = Queue.ToList();
|
||||
// var q = queueList.Shuffle().ToArray();
|
||||
//
|
||||
// bool found = false;
|
||||
// for (var i = 0; i < q.Length; i++) //first try to find a queuer who didn't have their song played recently
|
||||
// {
|
||||
// var item = q[i];
|
||||
// if (RecentlyPlayedUsers.Add(item.QueuerName)) // if it's found, set current song to that index
|
||||
// {
|
||||
// Queue.CurrentIndex = queueList.IndexOf(q[i]);
|
||||
// found = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!found) //if it's not
|
||||
// {
|
||||
// RecentlyPlayedUsers.Clear(); //clear all recently played users (that means everyone from the playlist has had their song played)
|
||||
// Queue.Random(); //go to a random song (to prevent looping on the first few songs)
|
||||
// var cur = Current;
|
||||
// if (cur.Current != null) // add newely scheduled song's queuer to the recently played list
|
||||
// RecentlyPlayedUsers.Add(cur.Current.QueuerName);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if (queueCount - 1 == data.Index && !RepeatPlaylist && !manualSkip)
|
||||
// {
|
||||
// Log.Information("Stopping because repeatplaylist is disabled");
|
||||
// lock (locker)
|
||||
// {
|
||||
// Stop();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Log.Information("Next song");
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (!Stopped)
|
||||
// if (!AutoDelete)
|
||||
// Queue.Next();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Log.Error(ex, "Error in queue");
|
||||
// }
|
||||
// }
|
||||
// do
|
||||
// {
|
||||
// await Task.Delay(500).ConfigureAwait(false);
|
||||
// }
|
||||
// while ((Queue.Count == 0 || Stopped) && !Exited);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private async Task<IAudioClient> GetAudioClient(bool reconnect = false)
|
||||
// {
|
||||
// if (_audioClient is null ||
|
||||
// _audioClient.ConnectionState != ConnectionState.Connected ||
|
||||
// reconnect ||
|
||||
// newVoiceChannel)
|
||||
// try
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var t = _audioClient?.StopAsync();
|
||||
// if (t != null)
|
||||
// {
|
||||
//
|
||||
// Log.Information("Stopping audio client");
|
||||
// await t.ConfigureAwait(false);
|
||||
//
|
||||
// Log.Information("Disposing audio client");
|
||||
// _audioClient.Dispose();
|
||||
// }
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// }
|
||||
// newVoiceChannel = false;
|
||||
//
|
||||
// var curUser = await VoiceChannel.Guild.GetCurrentUserAsync().ConfigureAwait(false);
|
||||
// if (curUser.VoiceChannel != null)
|
||||
// {
|
||||
// Log.Information("Connecting");
|
||||
// var ac = await VoiceChannel.ConnectAsync().ConfigureAwait(false);
|
||||
// Log.Information("Connected, stopping");
|
||||
// await ac.StopAsync().ConfigureAwait(false);
|
||||
// Log.Information("Disconnected");
|
||||
// await Task.Delay(1000).ConfigureAwait(false);
|
||||
// }
|
||||
// Log.Information("Connecting");
|
||||
// _audioClient = await VoiceChannel.ConnectAsync().ConfigureAwait(false);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Log.Warning("Error while getting audio client: {0}", ex.ToString());
|
||||
// return null;
|
||||
// }
|
||||
// return _audioClient;
|
||||
// }
|
||||
//
|
||||
// public int Enqueue(SongInfo song, bool forcePlay = false)
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (Exited)
|
||||
// return -1;
|
||||
// Queue.Add(song);
|
||||
// var result = Queue.Count - 1;
|
||||
//
|
||||
// if (forcePlay)
|
||||
// {
|
||||
// if (Stopped)
|
||||
// {
|
||||
// Stopped = false;
|
||||
// SetIndex(result);
|
||||
// }
|
||||
// Unpause();
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public int EnqueueNext(SongInfo song, bool forcePlay = false)
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (Exited)
|
||||
// return -1;
|
||||
// var toReturn = Queue.AddNext(song);
|
||||
// if (forcePlay)
|
||||
// {
|
||||
// Unpause();
|
||||
// if (Stopped)
|
||||
// {
|
||||
// SetIndex(toReturn);
|
||||
// }
|
||||
// }
|
||||
// return toReturn;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void SetIndex(int index)
|
||||
// {
|
||||
// if (index < 0)
|
||||
// throw new ArgumentOutOfRangeException(nameof(index));
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (Exited)
|
||||
// return;
|
||||
// if (AutoDelete && index >= Queue.CurrentIndex && index > 0)
|
||||
// index--;
|
||||
// Queue.CurrentIndex = index;
|
||||
// manualIndex = true;
|
||||
// Stopped = false;
|
||||
// CancelCurrentSong();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void Next(int skipCount = 1)
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (Exited)
|
||||
// return;
|
||||
// manualSkip = true;
|
||||
// // if player is stopped, and user uses .n, it should play current song.
|
||||
// // It's a bit weird, but that's the least annoying solution
|
||||
// if (!Stopped)
|
||||
// if (!RepeatPlaylist && Queue.IsLast() && !Autoplay) // if it's the last song in the queue, and repeat playlist is disabled
|
||||
// { //stop the queue
|
||||
// Stop();
|
||||
// return;
|
||||
// }
|
||||
// else
|
||||
// Queue.Next(skipCount - 1);
|
||||
// else
|
||||
// Queue.CurrentIndex = 0;
|
||||
// Stopped = false;
|
||||
// CancelCurrentSong();
|
||||
// Unpause();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void Stop(bool clearQueue = false)
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// Stopped = true;
|
||||
// Autoplay = false;
|
||||
// //Queue.ResetCurrent();
|
||||
// if (clearQueue)
|
||||
// Queue.Clear();
|
||||
// Unpause();
|
||||
// CancelCurrentSong();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void Unpause()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (PauseTaskSource != null)
|
||||
// {
|
||||
// PauseTaskSource.TrySetResult(true);
|
||||
// PauseTaskSource = null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void TogglePause()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (PauseTaskSource is null)
|
||||
// PauseTaskSource = new TaskCompletionSource<bool>();
|
||||
// else
|
||||
// {
|
||||
// Unpause();
|
||||
// }
|
||||
// }
|
||||
// OnPauseChanged?.Invoke(this, PauseTaskSource != null);
|
||||
// }
|
||||
//
|
||||
// public void SetVolume(int volume)
|
||||
// {
|
||||
// if (volume < 0 || volume > 100)
|
||||
// throw new ArgumentOutOfRangeException(nameof(volume));
|
||||
// lock (locker)
|
||||
// {
|
||||
// Volume = ((float)volume) / 100;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public SongInfo RemoveAt(int index)
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// var (Index, Song) = Queue.Current;
|
||||
// var toReturn = Queue.RemoveAt(index);
|
||||
// if (Index == index)
|
||||
// Next();
|
||||
// return toReturn;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void CancelCurrentSong()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// var cs = SongCancelSource;
|
||||
// SongCancelSource = new CancellationTokenSource();
|
||||
// cs.Cancel();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void ClearQueue()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// Queue.Clear();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public (int CurrentIndex, SongInfo[] Songs) QueueArray()
|
||||
// {
|
||||
// lock (locker)
|
||||
// return Queue.ToArray();
|
||||
// }
|
||||
//
|
||||
// //aidiakapi ftw
|
||||
// // public static unsafe byte[] AdjustVolume(byte[] audioSamples, float volume)
|
||||
// // {
|
||||
// // if (Math.Abs(volume - 1f) < 0.0001f) return audioSamples;
|
||||
// //
|
||||
// // // 16-bit precision for the multiplication
|
||||
// // var volumeFixed = (int)Math.Round(volume * 65536d);
|
||||
// //
|
||||
// // var count = audioSamples.Length / 2;
|
||||
// //
|
||||
// // fixed (byte* srcBytes = audioSamples)
|
||||
// // {
|
||||
// // var src = (short*)srcBytes;
|
||||
// //
|
||||
// // for (var i = count; i != 0; i--, src++)
|
||||
// // *src = (short)(((*src) * volumeFixed) >> 16);
|
||||
// // }
|
||||
// //
|
||||
// // return audioSamples;
|
||||
// // }
|
||||
//
|
||||
// private static void AdjustVolume(byte[] audioSamples, float volume)
|
||||
// {
|
||||
// if (Math.Abs(volume - 1f) < 0.0001f) return;
|
||||
//
|
||||
// var samples = MemoryMarshal.Cast<byte, short>(audioSamples);
|
||||
//
|
||||
// for (var i = 0; i < samples.Length; i++)
|
||||
// {
|
||||
// ref var sample = ref samples[i];
|
||||
// sample = (short) (sample * volume);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public bool ToggleRepeatSong()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// return RepeatCurrentSong = !RepeatCurrentSong;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public async Task Destroy()
|
||||
// {
|
||||
// Log.Information("Destroying");
|
||||
// lock (locker)
|
||||
// {
|
||||
// Stop();
|
||||
// Exited = true;
|
||||
// Unpause();
|
||||
//
|
||||
// OnCompleted = null;
|
||||
// OnPauseChanged = null;
|
||||
// OnStarted = null;
|
||||
// }
|
||||
// var ac = _audioClient;
|
||||
// if (ac != null)
|
||||
// await ac.StopAsync().ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// public bool ToggleShuffle()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// return Shuffle = !Shuffle;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public bool ToggleAutoplay()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// return Autoplay = !Autoplay;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public bool ToggleRepeatPlaylist()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// return RepeatPlaylist = !RepeatPlaylist;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public async Task SetVoiceChannel(IVoiceChannel vch)
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (Exited)
|
||||
// return;
|
||||
// VoiceChannel = vch;
|
||||
// }
|
||||
// _audioClient = await vch.ConnectAsync().ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// public async Task UpdateSongDurationsAsync()
|
||||
// {
|
||||
// var (_, songs) = Queue.ToArray();
|
||||
// var toUpdate = songs
|
||||
// .Where(x => x.ProviderType == MusicType.YouTube
|
||||
// && x.TotalTime == TimeSpan.Zero);
|
||||
//
|
||||
// var vIds = toUpdate.Select(x => x.VideoId);
|
||||
// if (!vIds.Any())
|
||||
// return;
|
||||
//
|
||||
// var durations = await _google.GetVideoDurationsAsync(vIds).ConfigureAwait(false);
|
||||
//
|
||||
// foreach (var x in toUpdate)
|
||||
// {
|
||||
// if (durations.TryGetValue(x.VideoId, out var dur))
|
||||
// x.TotalTime = dur;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public SongInfo MoveSong(int n1, int n2)
|
||||
// => Queue.MoveSong(n1, n2);
|
||||
//
|
||||
// public void SetMusicChannelToOriginal()
|
||||
// {
|
||||
// this.OutputTextChannel = OriginalTextChannel;
|
||||
// }
|
||||
//
|
||||
// //// this should be written better
|
||||
// //public TimeSpan TotalPlaytime =>
|
||||
// // _playlist.Any(s => s.TotalTime == TimeSpan.MaxValue) ?
|
||||
// // TimeSpan.MaxValue :
|
||||
// // new TimeSpan(_playlist.Sum(s => s.TotalTime.Ticks));
|
||||
// }
|
||||
// }
|
@@ -1,223 +0,0 @@
|
||||
// using NadekoBot.Extensions;
|
||||
// using NadekoBot.Modules.Music.Common.Exceptions;
|
||||
// using System;
|
||||
// using System.Collections.Generic;
|
||||
// using System.Linq;
|
||||
// using System.Threading.Tasks;
|
||||
// using NadekoBot.Common;
|
||||
//
|
||||
// namespace NadekoBot.Modules.Music.Common
|
||||
// {
|
||||
// public sealed class MusicQueue : IDisposable
|
||||
// {
|
||||
// private LinkedList<SongInfo> Songs { get; set; } = new LinkedList<SongInfo>();
|
||||
// private int _currentIndex = 0;
|
||||
// public int CurrentIndex
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return _currentIndex;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (Songs.Count == 0)
|
||||
// _currentIndex = 0;
|
||||
// else
|
||||
// _currentIndex = value %= Songs.Count;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// public (int Index, SongInfo Song) Current
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// var cur = CurrentIndex;
|
||||
// return (cur, Songs.ElementAtOrDefault(cur));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private readonly object locker = new object();
|
||||
// private TaskCompletionSource<bool> nextSource { get; } = new TaskCompletionSource<bool>();
|
||||
// public int Count
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// return Songs.Count;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private uint _maxQueueSize;
|
||||
// public uint MaxQueueSize
|
||||
// {
|
||||
// get => _maxQueueSize;
|
||||
// set
|
||||
// {
|
||||
// if (value < 0)
|
||||
// throw new ArgumentOutOfRangeException(nameof(value));
|
||||
//
|
||||
// lock (locker)
|
||||
// {
|
||||
// _maxQueueSize = value;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void Add(SongInfo song)
|
||||
// {
|
||||
// song.ThrowIfNull(nameof(song));
|
||||
// lock (locker)
|
||||
// {
|
||||
// if(MaxQueueSize != 0 && Songs.Count >= MaxQueueSize)
|
||||
// throw new QueueFullException();
|
||||
// Songs.AddLast(song);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public int AddNext(SongInfo song)
|
||||
// {
|
||||
// song.ThrowIfNull(nameof(song));
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (MaxQueueSize != 0 && Songs.Count >= MaxQueueSize)
|
||||
// throw new QueueFullException();
|
||||
// var curSong = Current.Song;
|
||||
// if (curSong is null)
|
||||
// {
|
||||
// Songs.AddLast(song);
|
||||
// return Songs.Count;
|
||||
// }
|
||||
//
|
||||
// var songlist = Songs.ToList();
|
||||
// songlist.Insert(CurrentIndex + 1, song);
|
||||
// Songs = new LinkedList<SongInfo>(songlist);
|
||||
// return CurrentIndex + 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void Next(int skipCount = 1)
|
||||
// {
|
||||
// lock(locker)
|
||||
// CurrentIndex += skipCount;
|
||||
// }
|
||||
//
|
||||
// public void Dispose()
|
||||
// {
|
||||
// Clear();
|
||||
// }
|
||||
//
|
||||
// public SongInfo RemoveAt(int index)
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// if (index < 0 || index >= Songs.Count)
|
||||
// throw new ArgumentOutOfRangeException(nameof(index));
|
||||
//
|
||||
// var current = Songs.First.Value;
|
||||
// for (int i = 0; i < Songs.Count; i++)
|
||||
// {
|
||||
// if (i == index)
|
||||
// {
|
||||
// current = Songs.ElementAt(index);
|
||||
// Songs.Remove(current);
|
||||
// if (CurrentIndex != 0)
|
||||
// {
|
||||
// if (CurrentIndex >= index)
|
||||
// {
|
||||
// --CurrentIndex;
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return current;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void Clear()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// Songs.Clear();
|
||||
// CurrentIndex = 0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public (int CurrentIndex, SongInfo[] Songs) ToArray()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// return (CurrentIndex, Songs.ToArray());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public List<SongInfo> ToList()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// return Songs.ToList();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void ResetCurrent()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// CurrentIndex = 0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void Random()
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// CurrentIndex = new NadekoRandom().Next(Songs.Count);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public SongInfo MoveSong(int n1, int n2)
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// var currentSong = Current.Song;
|
||||
// var playlist = Songs.ToList();
|
||||
// if (n1 >= playlist.Count || n2 >= playlist.Count || n1 == n2)
|
||||
// return null;
|
||||
//
|
||||
// var s = playlist[n1];
|
||||
//
|
||||
// playlist.RemoveAt(n1);
|
||||
// playlist.Insert(n2, s);
|
||||
//
|
||||
// Songs = new LinkedList<SongInfo>(playlist);
|
||||
//
|
||||
//
|
||||
// if (currentSong != null)
|
||||
// CurrentIndex = playlist.IndexOf(currentSong);
|
||||
//
|
||||
// return s;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void RemoveSong(SongInfo song)
|
||||
// {
|
||||
// lock (locker)
|
||||
// {
|
||||
// Songs.Remove(song);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public bool IsLast()
|
||||
// {
|
||||
// lock (locker)
|
||||
// return CurrentIndex == Songs.Count - 1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //O O [O] O O O O
|
||||
// //
|
||||
// // 3
|
@@ -155,7 +155,7 @@ namespace NadekoBot.Modules.Music
|
||||
}
|
||||
|
||||
// join vc
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Join()
|
||||
{
|
||||
@@ -173,7 +173,7 @@ namespace NadekoBot.Modules.Music
|
||||
}
|
||||
|
||||
// leave vc (destroy)
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Destroy()
|
||||
{
|
||||
@@ -185,37 +185,37 @@ namespace NadekoBot.Modules.Music
|
||||
}
|
||||
|
||||
// play - no args = next
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(2)]
|
||||
public Task Play()
|
||||
=> Next();
|
||||
|
||||
// play - index = skip to that index
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(1)]
|
||||
public Task Play(int index)
|
||||
=> MoveToIndex(index);
|
||||
|
||||
// play - query = q(query)
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(0)]
|
||||
public Task Play([Leftover] string query)
|
||||
=> QueueByQuery(query);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public Task Queue([Leftover] string query)
|
||||
=> QueueByQuery(query);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public Task QueueNext([Leftover] string query)
|
||||
=> QueueByQuery(query, asNext: true);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Volume(int vol)
|
||||
{
|
||||
@@ -233,7 +233,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ReplyConfirmLocalizedAsync("volume_set", vol);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Next()
|
||||
{
|
||||
@@ -252,7 +252,7 @@ namespace NadekoBot.Modules.Music
|
||||
private const int LQ_ITEMS_PER_PAGE = 9;
|
||||
|
||||
// list queue, relevant page
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ListQueue()
|
||||
{
|
||||
@@ -267,7 +267,7 @@ namespace NadekoBot.Modules.Music
|
||||
}
|
||||
|
||||
// list queue, specify page
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ListQueue(int page)
|
||||
{
|
||||
@@ -348,7 +348,7 @@ namespace NadekoBot.Modules.Music
|
||||
}
|
||||
|
||||
// search
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task QueueSearch([Leftover] string query)
|
||||
{
|
||||
@@ -404,7 +404,7 @@ namespace NadekoBot.Modules.Music
|
||||
}
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(1)]
|
||||
public async Task TrackRemove(int index)
|
||||
@@ -441,7 +441,7 @@ namespace NadekoBot.Modules.Music
|
||||
}
|
||||
|
||||
public enum All { All = -1 }
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(0)]
|
||||
public async Task TrackRemove(All _ = All.All)
|
||||
@@ -460,7 +460,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ReplyConfirmLocalizedAsync("queue_cleared").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Stop()
|
||||
{
|
||||
@@ -492,7 +492,7 @@ namespace NadekoBot.Modules.Music
|
||||
_ => PlayerRepeatType.Queue
|
||||
};
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task QueueRepeat(InputRepeatType type = InputRepeatType.Queue)
|
||||
{
|
||||
@@ -510,7 +510,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ReplyConfirmLocalizedAsync("repeating_track");
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ReptCurSong()
|
||||
{
|
||||
@@ -518,7 +518,7 @@ namespace NadekoBot.Modules.Music
|
||||
await QueueRepeat(InputRepeatType.Song);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Pause()
|
||||
{
|
||||
@@ -535,18 +535,18 @@ namespace NadekoBot.Modules.Music
|
||||
mp.TogglePause();
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public Task Radio(string radioLink)
|
||||
=> QueueByQuery(radioLink, false, MusicPlatform.Radio);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public Task Local([Leftover] string path)
|
||||
=> QueueByQuery(path, false, MusicPlatform.Local);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
public async Task LocalPlaylist([Leftover] string dirPath)
|
||||
@@ -586,7 +586,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ReplyConfirmLocalizedAsync("dir_queue_complete").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task MoveSong(int from, int to)
|
||||
{
|
||||
@@ -627,12 +627,12 @@ namespace NadekoBot.Modules.Music
|
||||
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public Task SoundCloudQueue([Leftover] string query)
|
||||
=> QueueByQuery(query, false, MusicPlatform.SoundCloud);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task SoundCloudPl([Leftover] string playlist)
|
||||
{
|
||||
@@ -657,7 +657,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Playlist([Leftover] string playlistQuery)
|
||||
{
|
||||
@@ -687,7 +687,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task NowPlaying()
|
||||
{
|
||||
@@ -711,7 +711,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task PlaylistShuffle()
|
||||
{
|
||||
@@ -730,7 +730,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ReplyConfirmLocalizedAsync("queue_shuffled");
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.ManageMessages)]
|
||||
public async Task SetMusicChannel()
|
||||
@@ -740,7 +740,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ReplyConfirmLocalizedAsync("set_music_channel");
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.ManageMessages)]
|
||||
public async Task UnsetMusicChannel()
|
||||
@@ -750,7 +750,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ReplyConfirmLocalizedAsync("unset_music_channel");
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task AutoDisconnect()
|
||||
{
|
||||
@@ -762,7 +762,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ReplyConfirmLocalizedAsync("autodc_disable");
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequireUserPermission(GuildPermission.Administrator)]
|
||||
public async Task MusicQuality()
|
||||
@@ -771,7 +771,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ReplyConfirmLocalizedAsync("current_music_quality", Format.Bold(quality.ToString()));
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequireUserPermission(GuildPermission.Administrator)]
|
||||
public async Task MusicQuality(QualityPreset preset)
|
||||
|
@@ -47,7 +47,7 @@ namespace NadekoBot.Modules.Music
|
||||
}
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Playlists([Leftover] int num = 1)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task DeletePlaylist([Leftover] int id)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Music
|
||||
await ReplyConfirmLocalizedAsync("playlist_deleted").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task PlaylistShow(int id, int page = 1)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ namespace NadekoBot.Modules.Music
|
||||
}, mpl.Songs.Count, 20).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Save([Leftover] string name)
|
||||
{
|
||||
@@ -172,7 +172,7 @@ namespace NadekoBot.Modules.Music
|
||||
|
||||
private static readonly SemaphoreSlim _playlistLock = new SemaphoreSlim(1, 1);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Load([Leftover] int id)
|
||||
{
|
||||
|
@@ -1,297 +0,0 @@
|
||||
// using System.Collections.Concurrent;
|
||||
// using System.Linq;
|
||||
// using System.Threading.Tasks;
|
||||
// using Discord;
|
||||
// using NadekoBot.Extensions;
|
||||
// using NadekoBot.Services.Database.Models;
|
||||
// using System.IO;
|
||||
// using Discord.Commands;
|
||||
// using Discord.WebSocket;
|
||||
// using NadekoBot.Common;
|
||||
// using NadekoBot.Services;
|
||||
// using NadekoBot.Services;
|
||||
// using NadekoBot.Modules.Music.Common;
|
||||
// using NadekoBot.Modules.Music.Common.Exceptions;
|
||||
// using NadekoBot.Modules.Music.Common.SongResolver;
|
||||
// using NadekoBot.Common.Collections;
|
||||
// using Microsoft.EntityFrameworkCore;
|
||||
// using Serilog;
|
||||
//
|
||||
// namespace NadekoBot.Modules.Music.Services
|
||||
// {
|
||||
// public class MusicService : INService, IUnloadableService
|
||||
// {
|
||||
// public const string MusicDataPath = "data/musicdata";
|
||||
//
|
||||
// private readonly IGoogleApiService _google;
|
||||
// private readonly IBotStrings _strings;
|
||||
// private readonly DbService _db;
|
||||
// private readonly AyuVoiceStateService _tracker;
|
||||
// private readonly ConcurrentDictionary<ulong, MusicSettings> _musicSettings;
|
||||
// private readonly SoundCloudApiService _sc;
|
||||
// private readonly IBotCredentials _creds;
|
||||
// private readonly ConcurrentDictionary<ulong, float> _defaultVolumes;
|
||||
//
|
||||
// public ConcurrentHashSet<ulong> AutoDcServers { get; }
|
||||
//
|
||||
// private readonly DiscordSocketClient _client;
|
||||
//
|
||||
// public ConcurrentDictionary<ulong, MusicPlayer> MusicPlayers { get; } = new ConcurrentDictionary<ulong, MusicPlayer>();
|
||||
//
|
||||
// public MusicService(DiscordSocketClient client, IGoogleApiService google,
|
||||
// IBotStrings strings, DbService db, AyuVoiceStateService tracker,
|
||||
// SoundCloudApiService sc, IBotCredentials creds, NadekoBot bot)
|
||||
// {
|
||||
// _client = client;
|
||||
// _google = google;
|
||||
// _strings = strings;
|
||||
// _db = db;
|
||||
// _tracker = tracker;
|
||||
// _sc = sc;
|
||||
// _creds = creds;
|
||||
// _musicSettings = bot.AllGuildConfigs.ToDictionary(x => x.GuildId, x => x.MusicSettings)
|
||||
// .ToConcurrent();
|
||||
//
|
||||
// _client.LeftGuild += _client_LeftGuild;
|
||||
// try { Directory.Delete(MusicDataPath, true); } catch { }
|
||||
//
|
||||
// _defaultVolumes = new ConcurrentDictionary<ulong, float>(
|
||||
// bot.AllGuildConfigs
|
||||
// .ToDictionary(x => x.GuildId, x => x.DefaultMusicVolume));
|
||||
//
|
||||
// AutoDcServers = new ConcurrentHashSet<ulong>(bot.AllGuildConfigs.Where(x => x.AutoDcFromVc).Select(x => x.GuildId));
|
||||
//
|
||||
// Directory.CreateDirectory(MusicDataPath);
|
||||
// }
|
||||
//
|
||||
// public Task Unload()
|
||||
// {
|
||||
// _client.LeftGuild -= _client_LeftGuild;
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
//
|
||||
// private Task _client_LeftGuild(SocketGuild arg)
|
||||
// {
|
||||
// var t = DestroyPlayer(arg.Id);
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
//
|
||||
// public float GetDefaultVolume(ulong guildId)
|
||||
// {
|
||||
// return _defaultVolumes.GetOrAdd(guildId, (id) =>
|
||||
// {
|
||||
// using (var uow = _db.GetDbContext())
|
||||
// {
|
||||
// return uow.GuildConfigsForId(guildId, set => set).DefaultMusicVolume;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// public Task<MusicPlayer> GetOrCreatePlayer(ICommandContext context)
|
||||
// {
|
||||
// var gUsr = (IGuildUser)context.User;
|
||||
// var txtCh = (ITextChannel)context.Channel;
|
||||
// var vCh = gUsr.VoiceChannel;
|
||||
// return GetOrCreatePlayer(context.Guild.Id, vCh, txtCh);
|
||||
// }
|
||||
//
|
||||
// public async Task<MusicPlayer> GetOrCreatePlayer(ulong guildId, IVoiceChannel voiceCh, ITextChannel textCh)
|
||||
// {
|
||||
// string GetText(string text, params object[] replacements) =>
|
||||
// _strings.GetText(text, textCh.Guild.Id, replacements);
|
||||
//
|
||||
// if (voiceCh is null || voiceCh.Guild != textCh.Guild)
|
||||
// {
|
||||
// if (textCh != null)
|
||||
// {
|
||||
// await textCh.SendErrorAsync(GetText("must_be_in_voice")).ConfigureAwait(false);
|
||||
// }
|
||||
// throw new NotInVoiceChannelException();
|
||||
// }
|
||||
// return MusicPlayers.GetOrAdd(guildId, _ =>
|
||||
// {
|
||||
// var vol = GetDefaultVolume(guildId);
|
||||
// if (!_musicSettings.TryGetValue(guildId, out var ms))
|
||||
// ms = new MusicSettings();
|
||||
//
|
||||
// var mp = new MusicPlayer(this, ms, _google, voiceCh, textCh, vol, _tracker);
|
||||
//
|
||||
// IUserMessage playingMessage = null;
|
||||
// IUserMessage lastFinishedMessage = null;
|
||||
//
|
||||
// mp.OnCompleted += async (s, song) =>
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// lastFinishedMessage?.DeleteAfter(0);
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// lastFinishedMessage = await mp.OutputTextChannel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
// .WithAuthor(eab => eab.WithName(GetText("finished_song")).WithMusicIcon())
|
||||
// .WithDescription(song.PrettyName)
|
||||
// .WithFooter(ef => ef.WithText(song.PrettyInfo)))
|
||||
// .ConfigureAwait(false);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // ignored
|
||||
// }
|
||||
//
|
||||
// var (Index, Current) = mp.Current;
|
||||
// if (Current is null
|
||||
// && !mp.RepeatCurrentSong
|
||||
// && !mp.RepeatPlaylist
|
||||
// && !mp.FairPlay
|
||||
// && AutoDcServers.Contains(guildId))
|
||||
// {
|
||||
// await DestroyPlayer(guildId).ConfigureAwait(false);
|
||||
// }
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // ignored
|
||||
// }
|
||||
// };
|
||||
// mp.OnStarted += async (player, song) =>
|
||||
// {
|
||||
// //try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); }
|
||||
// //catch
|
||||
// //{
|
||||
// // // ignored
|
||||
// //}
|
||||
// var sender = player;
|
||||
// if (sender is null)
|
||||
// return;
|
||||
// try
|
||||
// {
|
||||
// playingMessage?.DeleteAfter(0);
|
||||
//
|
||||
// playingMessage = await mp.OutputTextChannel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
// .WithAuthor(eab => eab.WithName(GetText("playing_song", song.Index + 1)).WithMusicIcon())
|
||||
// .WithDescription(song.Song.PrettyName)
|
||||
// .WithFooter(ef => ef.WithText(mp.PrettyVolume + " | " + song.Song.PrettyInfo)))
|
||||
// .ConfigureAwait(false);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // ignored
|
||||
// }
|
||||
// };
|
||||
// mp.OnPauseChanged += async (player, paused) =>
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// IUserMessage msg;
|
||||
// if (paused)
|
||||
// msg = await mp.OutputTextChannel.SendConfirmAsync(GetText("paused")).ConfigureAwait(false);
|
||||
// else
|
||||
// msg = await mp.OutputTextChannel.SendConfirmAsync(GetText("resumed")).ConfigureAwait(false);
|
||||
//
|
||||
// msg?.DeleteAfter(10);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // ignored
|
||||
// }
|
||||
// };
|
||||
// Log.Information("Done creating");
|
||||
// return mp;
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// public MusicPlayer GetPlayerOrDefault(ulong guildId)
|
||||
// {
|
||||
// if (MusicPlayers.TryGetValue(guildId, out var mp))
|
||||
// return mp;
|
||||
// else
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public async Task TryQueueRelatedSongAsync(SongInfo song, ITextChannel txtCh, IVoiceChannel vch)
|
||||
// {
|
||||
// var related = (await _google.GetRelatedVideosAsync(song.VideoId, 4).ConfigureAwait(false)).ToArray();
|
||||
// if (!related.Any())
|
||||
// return;
|
||||
//
|
||||
// var si = await ResolveSong(related[new NadekoRandom().Next(related.Length)], _client.CurrentUser.ToString(), MusicType.YouTube).ConfigureAwait(false);
|
||||
// if (si is null)
|
||||
// throw new SongNotFoundException();
|
||||
// var mp = await GetOrCreatePlayer(txtCh.GuildId, vch, txtCh).ConfigureAwait(false);
|
||||
// mp.Enqueue(si);
|
||||
// }
|
||||
//
|
||||
// public async Task<SongInfo> ResolveSong(string query, string queuerName, MusicType? musicType = null)
|
||||
// {
|
||||
// query.ThrowIfNull(nameof(query));
|
||||
//
|
||||
// ISongResolverFactory resolverFactory = new SongResolverFactory(_sc);
|
||||
// var strategy = await resolverFactory.GetResolveStrategy(query, musicType).ConfigureAwait(false);
|
||||
// var sinfo = await strategy.ResolveSong(query).ConfigureAwait(false);
|
||||
//
|
||||
// if (sinfo is null)
|
||||
// return null;
|
||||
//
|
||||
// sinfo.QueuerName = queuerName;
|
||||
//
|
||||
// return sinfo;
|
||||
// }
|
||||
//
|
||||
// public async Task DestroyAllPlayers()
|
||||
// {
|
||||
// foreach (var key in MusicPlayers.Keys)
|
||||
// {
|
||||
// await DestroyPlayer(key).ConfigureAwait(false);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public async Task DestroyPlayer(ulong id)
|
||||
// {
|
||||
// if (MusicPlayers.TryRemove(id, out var mp))
|
||||
// await mp.Destroy().ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// public bool ToggleAutoDc(ulong id)
|
||||
// {
|
||||
// bool val;
|
||||
// using (var uow = _db.GetDbContext())
|
||||
// {
|
||||
// var gc = uow.GuildConfigsForId(id, set => set);
|
||||
// val = gc.AutoDcFromVc = !gc.AutoDcFromVc;
|
||||
// uow.SaveChanges();
|
||||
// }
|
||||
//
|
||||
// if (val)
|
||||
// AutoDcServers.Add(id);
|
||||
// else
|
||||
// AutoDcServers.TryRemove(id);
|
||||
//
|
||||
// return val;
|
||||
// }
|
||||
//
|
||||
// public void UpdateSettings(ulong id, MusicSettings musicSettings)
|
||||
// {
|
||||
// _musicSettings.AddOrUpdate(id, musicSettings, delegate { return musicSettings; });
|
||||
// }
|
||||
//
|
||||
// public void SetMusicChannel(ulong guildId, ulong? cid)
|
||||
// {
|
||||
// using (var uow = _db.GetDbContext())
|
||||
// {
|
||||
// var ms = uow.GuildConfigsForId(guildId, set => set.Include(x => x.MusicSettings)).MusicSettings;
|
||||
// ms.MusicChannelId = cid;
|
||||
// uow.SaveChanges();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void SetSongAutoDelete(ulong guildId, bool val)
|
||||
// {
|
||||
// using (var uow = _db.GetDbContext())
|
||||
// {
|
||||
// var ms = uow.GuildConfigsForId(guildId, set => set.Include(x => x.MusicSettings)).MusicSettings;
|
||||
// ms.SongAutoDelete = val;
|
||||
// uow.SaveChanges();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
@@ -1,984 +0,0 @@
|
||||
// using Discord;
|
||||
// using Discord.Commands;
|
||||
// using Discord.WebSocket;
|
||||
// using NadekoBot.Common;
|
||||
// using NadekoBot.Common.Attributes;
|
||||
// using NadekoBot.Common.Collections;
|
||||
// using NadekoBot.Services;
|
||||
// using NadekoBot.Services.Database.Models;
|
||||
// using NadekoBot.Services;
|
||||
// using NadekoBot.Extensions;
|
||||
// using NadekoBot.Modules.Administration.Services;
|
||||
// using NadekoBot.Modules.Music.Common;
|
||||
// using NadekoBot.Modules.Music.Common.Exceptions;
|
||||
// using NadekoBot.Modules.Music.Extensions;
|
||||
// using NadekoBot.Modules.Music.Services;
|
||||
// using Newtonsoft.Json.Linq;
|
||||
// using System;
|
||||
// using System.Collections.Generic;
|
||||
// using System.IO;
|
||||
// using System.Linq;
|
||||
// using System.Net.Http;
|
||||
// using System.Threading.Tasks;
|
||||
// using Serilog;
|
||||
//
|
||||
// namespace NadekoBot.Modules.Music
|
||||
// {
|
||||
// [NoPublicBot]
|
||||
// public class Music : NadekoModule<MusicService>
|
||||
// {
|
||||
// private readonly DiscordSocketClient _client;
|
||||
// private readonly IBotCredentials _creds;
|
||||
// private readonly IGoogleApiService _google;
|
||||
// private readonly DbService _db;
|
||||
// private readonly LogCommandService _logService;
|
||||
//
|
||||
// public Music(DiscordSocketClient client,
|
||||
// IBotCredentials creds,
|
||||
// IGoogleApiService google,
|
||||
// DbService db,
|
||||
// LogCommandService logService)
|
||||
// {
|
||||
// _client = client;
|
||||
// _creds = creds;
|
||||
// _google = google;
|
||||
// _db = db;
|
||||
// _logService = logService;
|
||||
// }
|
||||
//
|
||||
// //private Task Client_UserVoiceStateUpdated(SocketUser iusr, SocketVoiceState oldState, SocketVoiceState newState)
|
||||
// //{
|
||||
// // var t = Task.Run(() =>
|
||||
// // {
|
||||
// // var usr = iusr as SocketGuildUser;
|
||||
// // if (usr is null ||
|
||||
// // oldState.VoiceChannel == newState.VoiceChannel)
|
||||
// // return;
|
||||
//
|
||||
// // var player = _music.GetPlayerOrDefault(usr.Guild.Id);
|
||||
//
|
||||
// // if (player is null)
|
||||
// // return;
|
||||
//
|
||||
// // try
|
||||
// // {
|
||||
// // //if bot moved
|
||||
// // if ((player.VoiceChannel == oldState.VoiceChannel) &&
|
||||
// // usr.Id == _client.CurrentUser.Id)
|
||||
// // {
|
||||
// // //if (player.Paused && newState.VoiceChannel.Users.Count > 1) //unpause if there are people in the new channel
|
||||
// // // player.TogglePause();
|
||||
// // //else if (!player.Paused && newState.VoiceChannel.Users.Count <= 1) // pause if there are no users in the new channel
|
||||
// // // player.TogglePause();
|
||||
//
|
||||
// // // player.SetVoiceChannel(newState.VoiceChannel);
|
||||
// // return;
|
||||
// // }
|
||||
//
|
||||
// // ////if some other user moved
|
||||
// // //if ((player.VoiceChannel == newState.VoiceChannel && //if joined first, and player paused, unpause
|
||||
// // // player.Paused &&
|
||||
// // // newState.VoiceChannel.Users.Count >= 2) || // keep in mind bot is in the channel (+1)
|
||||
// // // (player.VoiceChannel == oldState.VoiceChannel && // if left last, and player unpaused, pause
|
||||
// // // !player.Paused &&
|
||||
// // // oldState.VoiceChannel.Users.Count == 1))
|
||||
// // //{
|
||||
// // // player.TogglePause();
|
||||
// // // return;
|
||||
// // //}
|
||||
// // }
|
||||
// // catch
|
||||
// // {
|
||||
// // // ignored
|
||||
// // }
|
||||
// // });
|
||||
// // return Task.CompletedTask;
|
||||
// //}
|
||||
//
|
||||
// private async Task InternalQueue(MusicPlayer mp, SongInfo songInfo, bool silent, bool queueFirst = false, bool forcePlay = false)
|
||||
// {
|
||||
// if (songInfo is null)
|
||||
// {
|
||||
// if (!silent)
|
||||
// await ReplyErrorLocalizedAsync("song_not_found").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// int index;
|
||||
// try
|
||||
// {
|
||||
// index = queueFirst
|
||||
// ? mp.EnqueueNext(songInfo, forcePlay)
|
||||
// : mp.Enqueue(songInfo, forcePlay);
|
||||
// }
|
||||
// catch (QueueFullException)
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync("queue_full", mp.MaxQueueSize).ConfigureAwait(false);
|
||||
// throw;
|
||||
// }
|
||||
// if (index != -1)
|
||||
// {
|
||||
// if (!silent)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var embed = new EmbedBuilder().WithOkColor()
|
||||
// .WithAuthor(eab => eab.WithName(GetText("queued_song") + " #" + (index + 1)).WithMusicIcon())
|
||||
// .WithDescription($"{songInfo.PrettyName}\n{GetText("queue")} ")
|
||||
// .WithFooter(ef => ef.WithText(songInfo.PrettyProvider));
|
||||
//
|
||||
// if (Uri.IsWellFormedUriString(songInfo.Thumbnail, UriKind.Absolute))
|
||||
// embed.WithThumbnailUrl(songInfo.Thumbnail);
|
||||
//
|
||||
// var queuedMessage = await mp.OutputTextChannel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
// if (mp.Stopped)
|
||||
// {
|
||||
// (await ReplyErrorLocalizedAsync("queue_stopped", Format.Code(Prefix + "play")).ConfigureAwait(false)).DeleteAfter(10, _logService);
|
||||
// }
|
||||
// queuedMessage?.DeleteAfter(10, _logService);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// // ignored
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Play([Leftover] string query = null)
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// if (string.IsNullOrWhiteSpace(query))
|
||||
// {
|
||||
// await Next().ConfigureAwait(false);
|
||||
// }
|
||||
// else if (int.TryParse(query, out var index))
|
||||
// if (index >= 1)
|
||||
// mp.SetIndex(index - 1);
|
||||
// else
|
||||
// return;
|
||||
// else
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// await InternalPlay(query, forceplay: true).ConfigureAwait(false);
|
||||
// }
|
||||
// catch { }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public Task Queue([Leftover] string query)
|
||||
// => InternalPlay(query, forceplay: false);
|
||||
//
|
||||
// private async Task InternalPlay(string query, bool forceplay)
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var songInfo = await _service.ResolveSong(query, ctx.User.ToString()).ConfigureAwait(false);
|
||||
// try { await InternalQueue(mp, songInfo, false, forcePlay: forceplay).ConfigureAwait(false); } catch (QueueFullException) { return; }
|
||||
// if ((await ctx.Guild.GetCurrentUserAsync().ConfigureAwait(false)).GetPermissions((IGuildChannel)ctx.Channel).ManageMessages)
|
||||
// {
|
||||
// ctx.Message.DeleteAfter(10, _logService);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task QueueNext([Leftover] string query)
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var songInfo = await _service.ResolveSong(query, ctx.User.ToString()).ConfigureAwait(false);
|
||||
// try { await InternalQueue(mp, songInfo, false, true).ConfigureAwait(false); } catch (QueueFullException) { return; }
|
||||
// if ((await ctx.Guild.GetCurrentUserAsync().ConfigureAwait(false)).GetPermissions((IGuildChannel)ctx.Channel).ManageMessages)
|
||||
// {
|
||||
// ctx.Message.DeleteAfter(10, _logService);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task QueueSearch([Leftover] string query)
|
||||
// {
|
||||
// var videos = (await _google.GetVideoInfosByKeywordAsync(query, 5).ConfigureAwait(false))
|
||||
// .ToArray();
|
||||
//
|
||||
// if (!videos.Any())
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync("song_not_found").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// var msg = await ctx.Channel.SendConfirmAsync(string.Join("\n", videos.Select((x, i) => $"`{i + 1}.`\n\t{Format.Bold(x.Name)}\n\t{x.Url}"))).ConfigureAwait(false);
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// var input = await GetUserInputAsync(ctx.User.Id, ctx.Channel.Id).ConfigureAwait(false);
|
||||
// if (input is null
|
||||
// || !int.TryParse(input, out var index)
|
||||
// || (index -= 1) < 0
|
||||
// || index >= videos.Length)
|
||||
// {
|
||||
// _logService.AddDeleteIgnore(msg.Id);
|
||||
// try { await msg.DeleteAsync().ConfigureAwait(false); } catch { }
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// query = videos[index].Url;
|
||||
//
|
||||
// await Queue(query).ConfigureAwait(false);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// _logService.AddDeleteIgnore(msg.Id);
|
||||
// try { await msg.DeleteAsync().ConfigureAwait(false); } catch { }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task ListQueue(int page = 0)
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var (current, songs) = mp.QueueArray();
|
||||
//
|
||||
// if (!songs.Any())
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync("no_player").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (--page < -1)
|
||||
// return;
|
||||
//
|
||||
// try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
||||
//
|
||||
// const int itemsPerPage = 10;
|
||||
//
|
||||
// if (page == -1)
|
||||
// page = current / itemsPerPage;
|
||||
//
|
||||
// //if page is 0 (-1 after this decrement) that means default to the page current song is playing from
|
||||
// var total = mp.TotalPlaytime;
|
||||
// var totalStr = total == TimeSpan.MaxValue ? "∞" : GetText("time_format",
|
||||
// (int)total.TotalHours,
|
||||
// total.Minutes,
|
||||
// total.Seconds);
|
||||
// var maxPlaytime = mp.MaxPlaytimeSeconds;
|
||||
//
|
||||
// EmbedBuilder printAction(int curPage)
|
||||
// {
|
||||
// var startAt = itemsPerPage * curPage;
|
||||
// var number = 0 + startAt;
|
||||
// var desc = string.Join("\n", songs
|
||||
// .Skip(startAt)
|
||||
// .Take(itemsPerPage)
|
||||
// .Select(v =>
|
||||
// {
|
||||
// if (number++ == current)
|
||||
// return $"**⇒**`{number}.` {v.PrettyFullName}";
|
||||
// else
|
||||
// return $"`{number}.` {v.PrettyFullName}";
|
||||
// }));
|
||||
//
|
||||
// desc = $"`🔊` {songs[current].PrettyFullName}\n\n" + desc;
|
||||
//
|
||||
// var add = "";
|
||||
// if (mp.Stopped)
|
||||
// add += Format.Bold(GetText("queue_stopped", Format.Code(Prefix + "play"))) + "\n";
|
||||
// var mps = mp.MaxPlaytimeSeconds;
|
||||
// if (mps > 0)
|
||||
// add += Format.Bold(GetText("song_skips_after", TimeSpan.FromSeconds(mps).ToString("HH\\:mm\\:ss"))) + "\n";
|
||||
// if (mp.RepeatCurrentSong)
|
||||
// add += "🔂 " + GetText("repeating_cur_song") + "\n";
|
||||
// else if (mp.Shuffle)
|
||||
// add += "🔀 " + GetText("shuffling_playlist") + "\n";
|
||||
// else
|
||||
// {
|
||||
// if (mp.Autoplay)
|
||||
// add += "↪ " + GetText("autoplaying") + "\n";
|
||||
// if (mp.FairPlay && !mp.Autoplay)
|
||||
// add += " " + GetText("fairplay") + "\n";
|
||||
// else if (mp.RepeatPlaylist)
|
||||
// add += "🔁 " + GetText("repeating_playlist") + "\n";
|
||||
// }
|
||||
//
|
||||
// if (!string.IsNullOrWhiteSpace(add))
|
||||
// desc = add + "\n" + desc;
|
||||
//
|
||||
// var embed = new EmbedBuilder()
|
||||
// .WithAuthor(eab => eab.WithName(GetText("player_queue", curPage + 1, (songs.Length / itemsPerPage) + 1))
|
||||
// .WithMusicIcon())
|
||||
// .WithDescription(desc)
|
||||
// .WithFooter(ef => ef.WithText($"{mp.PrettyVolume} | {songs.Length} " +
|
||||
// $"{("tracks".SnPl(songs.Length))} | {totalStr}"))
|
||||
// .WithOkColor();
|
||||
//
|
||||
// return embed;
|
||||
// }
|
||||
//
|
||||
// await ctx.SendPaginatedConfirmAsync(page, printAction, songs.Length,
|
||||
// itemsPerPage, false).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Next(int skipCount = 1)
|
||||
// {
|
||||
// if (skipCount < 1)
|
||||
// return;
|
||||
//
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
//
|
||||
// mp.Next(skipCount);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Stop()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// mp.Stop();
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task AutoDisconnect()
|
||||
// {
|
||||
// var newVal = _service.ToggleAutoDc(ctx.Guild.Id);
|
||||
//
|
||||
// if (newVal)
|
||||
// await ReplyConfirmLocalizedAsync("autodc_enable").ConfigureAwait(false);
|
||||
// else
|
||||
// await ReplyConfirmLocalizedAsync("autodc_disable").ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Destroy()
|
||||
// {
|
||||
// await _service.DestroyPlayer(ctx.Guild.Id).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Pause()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// mp.TogglePause();
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Volume(int val)
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// if (val < 0 || val > 100)
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync("volume_input_invalid").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// mp.SetVolume(val);
|
||||
// await ReplyConfirmLocalizedAsync("volume_set", val).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Defvol([Leftover] int val)
|
||||
// {
|
||||
// if (val < 0 || val > 100)
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync("volume_input_invalid").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// using (var uow = _db.GetDbContext())
|
||||
// {
|
||||
// uow.GuildConfigsForId(ctx.Guild.Id, set => set).DefaultMusicVolume = val / 100.0f;
|
||||
// uow.SaveChanges();
|
||||
// }
|
||||
// await ReplyConfirmLocalizedAsync("defvol_set", val).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// [Priority(1)]
|
||||
// public async Task SongRemove(int index)
|
||||
// {
|
||||
// if (index < 1)
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync("removed_song_error").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// try
|
||||
// {
|
||||
// var song = mp.RemoveAt(index - 1);
|
||||
// var embed = new EmbedBuilder()
|
||||
// .WithAuthor(eab => eab.WithName(GetText("removed_song") + " #" + (index)).WithMusicIcon())
|
||||
// .WithDescription(song.PrettyName)
|
||||
// .WithFooter(ef => ef.WithText(song.PrettyInfo))
|
||||
// .WithErrorColor();
|
||||
//
|
||||
// await mp.OutputTextChannel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
// }
|
||||
// catch (ArgumentOutOfRangeException)
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync("removed_song_error").ConfigureAwait(false);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public enum All { All }
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// [Priority(0)]
|
||||
// public async Task SongRemove(All _)
|
||||
// {
|
||||
// var mp = _service.GetPlayerOrDefault(ctx.Guild.Id);
|
||||
// if (mp is null)
|
||||
// return;
|
||||
// mp.Stop(true);
|
||||
// await ReplyConfirmLocalizedAsync("queue_cleared").ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Playlists([Leftover] int num = 1)
|
||||
// {
|
||||
// if (num <= 0)
|
||||
// return;
|
||||
//
|
||||
// List<MusicPlaylist> playlists;
|
||||
//
|
||||
// using (var uow = _db.GetDbContext())
|
||||
// {
|
||||
// playlists = uow.MusicPlaylists.GetPlaylistsOnPage(num);
|
||||
// }
|
||||
//
|
||||
// var embed = new EmbedBuilder()
|
||||
// .WithAuthor(eab => eab.WithName(GetText("playlists_page", num)).WithMusicIcon())
|
||||
// .WithDescription(string.Join("\n", playlists.Select(r =>
|
||||
// GetText("playlists", r.Id, r.Name, r.Author, r.Songs.Count))))
|
||||
// .WithOkColor();
|
||||
// await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task DeletePlaylist([Leftover] int id)
|
||||
// {
|
||||
// var success = false;
|
||||
// try
|
||||
// {
|
||||
// using (var uow = _db.GetDbContext())
|
||||
// {
|
||||
// var pl = uow.MusicPlaylists.GetById(id);
|
||||
//
|
||||
// if (pl != null)
|
||||
// {
|
||||
// if (_creds.IsOwner(ctx.User) || pl.AuthorId == ctx.User.Id)
|
||||
// {
|
||||
// uow.MusicPlaylists.Remove(pl);
|
||||
// await uow.SaveChangesAsync();
|
||||
// success = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Log.Warning(ex, "Error deleting playlist");
|
||||
// }
|
||||
//
|
||||
// if (!success)
|
||||
// await ReplyErrorLocalizedAsync("playlist_delete_fail").ConfigureAwait(false);
|
||||
// else
|
||||
// await ReplyConfirmLocalizedAsync("playlist_deleted").ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task PlaylistShow(int id, int page = 1)
|
||||
// {
|
||||
// if (page-- < 1)
|
||||
// return;
|
||||
//
|
||||
// MusicPlaylist mpl;
|
||||
// using (var uow = _db.GetDbContext())
|
||||
// {
|
||||
// mpl = uow.MusicPlaylists.GetWithSongs(id);
|
||||
// }
|
||||
//
|
||||
// await ctx.SendPaginatedConfirmAsync(page, (cur) =>
|
||||
// {
|
||||
// var i = 0;
|
||||
// var str = string.Join("\n", mpl.Songs
|
||||
// .Skip(cur * 20)
|
||||
// .Take(20)
|
||||
// .Select(x => $"`{++i}.` [{x.Title.TrimTo(45)}]({x.Query}) `{x.Provider}`"));
|
||||
// return new EmbedBuilder()
|
||||
// .WithTitle($"\"{mpl.Name}\" by {mpl.Author}")
|
||||
// .WithOkColor()
|
||||
// .WithDescription(str);
|
||||
// }, mpl.Songs.Count, 20).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Save([Leftover] string name)
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
//
|
||||
// var songs = mp.QueueArray().Songs
|
||||
// .Select(s => new PlaylistSong()
|
||||
// {
|
||||
// Provider = s.Provider,
|
||||
// ProviderType = s.ProviderType,
|
||||
// Title = s.Title,
|
||||
// Query = s.Query,
|
||||
// }).ToList();
|
||||
//
|
||||
// MusicPlaylist playlist;
|
||||
// using (var uow = _db.GetDbContext())
|
||||
// {
|
||||
// playlist = new MusicPlaylist
|
||||
// {
|
||||
// Name = name,
|
||||
// Author = ctx.User.Username,
|
||||
// AuthorId = ctx.User.Id,
|
||||
// Songs = songs.ToList(),
|
||||
// };
|
||||
// uow.MusicPlaylists.Add(playlist);
|
||||
// await uow.SaveChangesAsync();
|
||||
// }
|
||||
//
|
||||
// await ctx.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
// .WithTitle(GetText("playlist_saved"))
|
||||
// .AddField(efb => efb.WithName(GetText("name")).WithValue(name))
|
||||
// .AddField(efb => efb.WithName(GetText("id")).WithValue(playlist.Id.ToString()))).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// private static readonly ConcurrentHashSet<ulong> PlaylistLoadBlacklist = new ConcurrentHashSet<ulong>();
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Load([Leftover] int id)
|
||||
// {
|
||||
// if (!PlaylistLoadBlacklist.Add(ctx.Guild.Id))
|
||||
// return;
|
||||
// try
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// MusicPlaylist mpl;
|
||||
// using (var uow = _db.GetDbContext())
|
||||
// {
|
||||
// mpl = uow.MusicPlaylists.GetWithSongs(id);
|
||||
// }
|
||||
//
|
||||
// if (mpl is null)
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync("playlist_id_not_found").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// IUserMessage msg = null;
|
||||
// try
|
||||
// {
|
||||
// msg = await ctx.Channel
|
||||
// .SendMessageAsync(GetText("attempting_to_queue", Format.Bold(mpl.Songs.Count.ToString())))
|
||||
// .ConfigureAwait(false);
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// foreach (var item in mpl.Songs)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// await Task.Yield();
|
||||
// var song = await _service.ResolveSong(item.Query,
|
||||
// ctx.User.ToString(),
|
||||
// item.ProviderType).ConfigureAwait(false);
|
||||
// var queueTask = InternalQueue(mp, song, true);
|
||||
// await Task.WhenAll(Task.Delay(1000), queueTask).ConfigureAwait(false);
|
||||
// }
|
||||
// catch (SongNotFoundException) { }
|
||||
// catch { break; }
|
||||
// }
|
||||
// if (msg != null)
|
||||
// await msg.ModifyAsync(m => m.Content = GetText("playlist_queue_complete")).ConfigureAwait(false);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// PlaylistLoadBlacklist.TryRemove(ctx.Guild.Id);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Fairplay()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var val = mp.FairPlay = !mp.FairPlay;
|
||||
//
|
||||
// if (val)
|
||||
// {
|
||||
// await ReplyConfirmLocalizedAsync("fp_enabled").ConfigureAwait(false);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// await ReplyConfirmLocalizedAsync("fp_disabled").ConfigureAwait(false);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task SongAutoDelete()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var val = mp.AutoDelete = !mp.AutoDelete;
|
||||
//
|
||||
// _service.SetSongAutoDelete(ctx.Guild.Id, val);
|
||||
// if (val)
|
||||
// {
|
||||
// await ReplyConfirmLocalizedAsync("sad_enabled").ConfigureAwait(false);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// await ReplyConfirmLocalizedAsync("sad_disabled").ConfigureAwait(false);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task SoundCloudQueue([Leftover] string query)
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var song = await _service.ResolveSong(query, ctx.User.ToString(), MusicType.Soundcloud).ConfigureAwait(false);
|
||||
// await InternalQueue(mp, song, false).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task SoundCloudPl([Leftover] string pl)
|
||||
// {
|
||||
// pl = pl?.Trim();
|
||||
//
|
||||
// if (string.IsNullOrWhiteSpace(pl))
|
||||
// return;
|
||||
//
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
//
|
||||
// using (var http = new HttpClient())
|
||||
// {
|
||||
// var scvids = JObject.Parse(await http.GetStringAsync($"https://scapi.nadeko.bot/resolve?url={pl}").ConfigureAwait(false))["tracks"].ToObject<SoundCloudVideo[]>();
|
||||
// IUserMessage msg = null;
|
||||
// try { msg = await ctx.Channel.SendMessageAsync(GetText("attempting_to_queue", Format.Bold(scvids.Length.ToString()))).ConfigureAwait(false); } catch { }
|
||||
// foreach (var svideo in scvids)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var sinfo = await svideo.GetSongInfo().ConfigureAwait(false);
|
||||
// sinfo.QueuerName = ctx.User.ToString();
|
||||
// await InternalQueue(mp, sinfo, true).ConfigureAwait(false);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Log.Warning(ex, "Error queueing soundcloud song: {Title}", svideo.Title);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (msg != null)
|
||||
// await msg.ModifyAsync(m => m.Content = GetText("playlist_queue_complete")).ConfigureAwait(false);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task NowPlaying()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var (_, currentSong) = mp.Current;
|
||||
// if (currentSong is null)
|
||||
// return;
|
||||
// try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
||||
//
|
||||
// var embed = new EmbedBuilder().WithOkColor()
|
||||
// .WithAuthor(eab => eab.WithName(GetText("now_playing")).WithMusicIcon())
|
||||
// .WithDescription(currentSong.PrettyName)
|
||||
// .WithThumbnailUrl(currentSong.Thumbnail)
|
||||
// .WithFooter(ef => ef.WithText(mp.PrettyVolume + " | " + mp.PrettyFullTime + $" | {currentSong.PrettyProvider} | {currentSong.QueuerName}"));
|
||||
//
|
||||
// await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task PlaylistShuffle()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var val = mp.ToggleShuffle();
|
||||
// if (val)
|
||||
// await ReplyConfirmLocalizedAsync("songs_shuffle_enable").ConfigureAwait(false);
|
||||
// else
|
||||
// await ReplyConfirmLocalizedAsync("songs_shuffle_disable").ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Playlist([Leftover] string playlist)
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(playlist))
|
||||
// return;
|
||||
//
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
//
|
||||
// string plId = null;
|
||||
// try
|
||||
// {
|
||||
// plId = (await _google.GetPlaylistIdsByKeywordsAsync(playlist).ConfigureAwait(false)).FirstOrDefault();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Log.Warning(ex.Message);
|
||||
// }
|
||||
//
|
||||
// if (plId is null)
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync("no_search_results").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// var ids = await _google.GetPlaylistTracksAsync(plId, 500).ConfigureAwait(false);
|
||||
// if (!ids.Any())
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync("no_search_results").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// var count = ids.Count();
|
||||
// var msg = await ctx.Channel.SendMessageAsync("🎵 " + GetText("attempting_to_queue",
|
||||
// Format.Bold(count.ToString()))).ConfigureAwait(false);
|
||||
//
|
||||
// foreach (var song in ids)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (mp.Exited)
|
||||
// return;
|
||||
//
|
||||
// await Task.WhenAll(Task.Delay(150), InternalQueue(mp, await _service.ResolveSong(song, ctx.User.ToString(), MusicType.YouTube).ConfigureAwait(false), true)).ConfigureAwait(false);
|
||||
// }
|
||||
// catch (SongNotFoundException) { }
|
||||
// catch { break; }
|
||||
// }
|
||||
//
|
||||
// await msg.ModifyAsync(m => m.Content = "✅ " + Format.Bold(GetText("playlist_queue_complete"))).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Radio(string radioLink)
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var song = await _service.ResolveSong(radioLink, ctx.User.ToString(), MusicType.Radio).ConfigureAwait(false);
|
||||
// await InternalQueue(mp, song, false).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// [OwnerOnly]
|
||||
// public async Task Local([Leftover] string path)
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var song = await _service.ResolveSong(path, ctx.User.ToString(), MusicType.Local).ConfigureAwait(false);
|
||||
// await InternalQueue(mp, song, false).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// [OwnerOnly]
|
||||
// public async Task LocalPlaylist([Leftover] string dirPath)
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(dirPath))
|
||||
// return;
|
||||
//
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
//
|
||||
// DirectoryInfo dir;
|
||||
// try { dir = new DirectoryInfo(dirPath); } catch { return; }
|
||||
// var fileEnum = dir.GetFiles("*", SearchOption.AllDirectories)
|
||||
// .Where(x => !x.Attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System) && x.Extension != ".jpg" && x.Extension != ".png");
|
||||
// foreach (var file in fileEnum)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var song = await _service.ResolveSong(file.FullName, ctx.User.ToString(), MusicType.Local).ConfigureAwait(false);
|
||||
// await InternalQueue(mp, song, true).ConfigureAwait(false);
|
||||
// }
|
||||
// catch (QueueFullException)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Log.Warning(ex, "Error resolving local song {FileName}", file);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// await ReplyConfirmLocalizedAsync("dir_queue_complete").ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Move()
|
||||
// {
|
||||
// var vch = ((IGuildUser)ctx.User).VoiceChannel;
|
||||
//
|
||||
// if (vch is null)
|
||||
// return;
|
||||
//
|
||||
// var mp = _service.GetPlayerOrDefault(ctx.Guild.Id);
|
||||
//
|
||||
// if (mp is null)
|
||||
// return;
|
||||
//
|
||||
// await mp.SetVoiceChannel(vch).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task MoveSong([Leftover] string fromto)
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(fromto))
|
||||
// return;
|
||||
//
|
||||
// MusicPlayer mp = _service.GetPlayerOrDefault(ctx.Guild.Id);
|
||||
// if (mp is null)
|
||||
// return;
|
||||
//
|
||||
// fromto = fromto?.Trim();
|
||||
// var fromtoArr = fromto.Split('>');
|
||||
//
|
||||
// SongInfo s;
|
||||
// if (fromtoArr.Length != 2 || !int.TryParse(fromtoArr[0], out var n1) ||
|
||||
// !int.TryParse(fromtoArr[1], out var n2) || n1 < 1 || n2 < 1 || n1 == n2
|
||||
// || (s = mp.MoveSong(--n1, --n2)) is null)
|
||||
// {
|
||||
// await ReplyConfirmLocalizedAsync("invalid_input").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// var embed = new EmbedBuilder()
|
||||
// .WithTitle(s.Title.TrimTo(65))
|
||||
// .WithUrl(s.SongUrl)
|
||||
// .WithAuthor(eab => eab.WithName(GetText("song_moved")).WithIconUrl("https://cdn.discordapp.com/attachments/155726317222887425/258605269972549642/music1.png"))
|
||||
// .AddField(fb => fb.WithName(GetText("from_position")).WithValue($"#{n1 + 1}").WithIsInline(true))
|
||||
// .AddField(fb => fb.WithName(GetText("to_position")).WithValue($"#{n2 + 1}").WithIsInline(true))
|
||||
// .WithColor(NadekoBot.OkColor);
|
||||
//
|
||||
// await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task SetMaxQueue(uint size = 0)
|
||||
// {
|
||||
// if (size < 0)
|
||||
// return;
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
//
|
||||
// mp.MaxQueueSize = size;
|
||||
//
|
||||
// if (size == 0)
|
||||
// await ReplyConfirmLocalizedAsync("max_queue_unlimited").ConfigureAwait(false);
|
||||
// else
|
||||
// await ReplyConfirmLocalizedAsync("max_queue_x", size).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task SetMaxPlaytime(uint seconds)
|
||||
// {
|
||||
// if (seconds < 15 && seconds != 0)
|
||||
// return;
|
||||
//
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// mp.MaxPlaytimeSeconds = seconds;
|
||||
// if (seconds == 0)
|
||||
// await ReplyConfirmLocalizedAsync("max_playtime_none").ConfigureAwait(false);
|
||||
// else
|
||||
// await ReplyConfirmLocalizedAsync("max_playtime_set", seconds).ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task ReptCurSong()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var (_, currentSong) = mp.Current;
|
||||
// if (currentSong is null)
|
||||
// return;
|
||||
// var currentValue = mp.ToggleRepeatSong();
|
||||
//
|
||||
// if (currentValue)
|
||||
// await ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
// .WithOkColor()
|
||||
// .WithAuthor(eab => eab.WithMusicIcon().WithName("🔂 " + GetText("repeating_track")))
|
||||
// .WithDescription(currentSong.PrettyName)
|
||||
// .WithFooter(ef => ef.WithText(currentSong.PrettyInfo))).ConfigureAwait(false);
|
||||
// else
|
||||
// await ctx.Channel.SendConfirmAsync("🔂 " + GetText("repeating_track_stopped"))
|
||||
// .ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task PlaylistRepeat()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
// var currentValue = mp.ToggleRepeatPlaylist();
|
||||
// if (currentValue)
|
||||
// await ReplyConfirmLocalizedAsync("rpl_enabled").ConfigureAwait(false);
|
||||
// else
|
||||
// await ReplyConfirmLocalizedAsync("rpl_disabled").ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// public async Task Autoplay()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
//
|
||||
// if (!mp.ToggleAutoplay())
|
||||
// await ReplyConfirmLocalizedAsync("autoplay_disabled").ConfigureAwait(false);
|
||||
// else
|
||||
// await ReplyConfirmLocalizedAsync("autoplay_enabled").ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// [UserPerm(GuildPerm.ManageMessages)]
|
||||
// public async Task SetMusicChannel()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
//
|
||||
// mp.OutputTextChannel = (ITextChannel)ctx.Channel;
|
||||
// _service.SetMusicChannel(ctx.Guild.Id, ctx.Channel.Id);
|
||||
//
|
||||
// await ReplyConfirmLocalizedAsync("set_music_channel").ConfigureAwait(false);
|
||||
// }
|
||||
//
|
||||
// [NadekoCommand, Usage, Description, Aliases]
|
||||
// [RequireContext(ContextType.Guild)]
|
||||
// [UserPerm(GuildPerm.ManageMessages)]
|
||||
// public async Task UnsetMusicChannel()
|
||||
// {
|
||||
// var mp = await _service.GetOrCreatePlayer(Context).ConfigureAwait(false);
|
||||
//
|
||||
// mp.OutputTextChannel = mp.OriginalTextChannel;
|
||||
// _service.SetMusicChannel(ctx.Guild.Id, null);
|
||||
//
|
||||
// await ReplyConfirmLocalizedAsync("unset_music_channel").ConfigureAwait(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
Reference in New Issue
Block a user