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 //else if (!player.Paused && newState.VoiceChannel.Users.Count <= 1) // pause if there are no users in the new channel
// player.TogglePause(); // player.TogglePause();
player.SetVoiceChannel(newState.VoiceChannel); // player.SetVoiceChannel(newState.VoiceChannel);
return; return;
} }

View File

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

View File

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