.sad, .smch now persist restarts. .usmch added to unset music channel, since destroying a player won't reset it, Added --start-delay option for .race command

This commit is contained in:
Master Kwoth
2017-11-28 02:50:24 +07:00
parent 2ea157902e
commit 60e248c78a
10 changed files with 2168 additions and 10 deletions

View File

@ -11,6 +11,7 @@ using NadekoBot.Common.Collections;
using NadekoBot.Modules.Music.Services;
using NadekoBot.Core.Services;
using NadekoBot.Core.Services.Database.Models;
using Discord.WebSocket;
namespace NadekoBot.Modules.Music.Common
{
@ -25,6 +26,8 @@ namespace NadekoBot.Modules.Music.Common
{
private readonly Thread _player;
public IVoiceChannel VoiceChannel { get; private set; }
private readonly ITextChannel _originalTextChannel;
private readonly Logger _log;
private MusicQueue Queue { get; } = new MusicQueue();
@ -130,15 +133,19 @@ namespace NadekoBot.Modules.Music.Common
: new TimeSpan(songs.Sum(s => s.TotalTime.Ticks));
}
}
public MusicPlayer(MusicService musicService, IGoogleApiService google, IVoiceChannel vch, ITextChannel output, float volume)
public MusicPlayer(MusicService musicService, MusicSettings ms, IGoogleApiService google,
IVoiceChannel vch, ITextChannel original, float volume)
{
_log = LogManager.GetCurrentClassLogger();
this.Volume = volume;
this.VoiceChannel = vch;
this._originalTextChannel = original;
this.SongCancelSource = new CancellationTokenSource();
this.OutputTextChannel = output;
if(ms.MusicChannelId is ulong cid)
{
this.OutputTextChannel = ((SocketGuild)original.Guild).GetTextChannel(cid) ?? original;
}
this._musicService = musicService;
this._google = google;
@ -657,6 +664,11 @@ namespace NadekoBot.Modules.Music.Common
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) ?