Super weird fixes, i must've broke something else. Bot has to reconnect after restart now

This commit is contained in:
Master Kwoth 2017-07-03 21:05:35 +02:00
parent 89eabc7c14
commit f826fb97f6
3 changed files with 166 additions and 159 deletions

View File

@ -71,7 +71,7 @@ namespace NadekoBot.Modules.Music
//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);
// player.SetVoiceChannel(newState.VoiceChannel);
return;
}

View File

@ -123,8 +123,6 @@ namespace NadekoBot.Services.Music
manualSkip = false;
manualIndex = false;
}
try
{
if (data.Song == null)
continue;
@ -195,9 +193,6 @@ namespace NadekoBot.Services.Music
OnCompleted?.Invoke(this, data.Song);
}
}
}
finally
{
try
{
//if repeating current song, just ignore other settings,
@ -289,7 +284,6 @@ namespace NadekoBot.Services.Music
}
while ((Queue.Count == 0 || Stopped) && !Exited);
}
}
}, SongCancelSource.Token);
}
@ -319,13 +313,20 @@ namespace NadekoBot.Services.Music
if (t != null)
{
await t;
_audioClient?.Dispose();
_audioClient.Dispose();
}
}
catch
{
}
newVoiceChannel = false;
var curUser = await VoiceChannel.Guild.GetCurrentUserAsync();
_audioClient = await VoiceChannel.ConnectAsync();
if (curUser.VoiceChannel != null)
{
await _audioClient.StopAsync();
await Task.Delay(1000);
}
_audioClient = await VoiceChannel.ConnectAsync();
}
catch

View File

@ -111,11 +111,17 @@ Check the guides for your platform on how to setup ffmpeg correctly:
public void Dispose()
{
try
{
this.p.StandardOutput.Dispose();
}
catch (Exception ex)
{
_log.Error(ex);
}
try { this.p.Kill(); }
catch { }
_outStream.Dispose();
this.p.StandardError.Dispose();
this.p.StandardOutput.Dispose();
this.p.Dispose();
}
}