Skip to content

Commit

Permalink
Fixed kicking breaking playback.
Browse files Browse the repository at this point in the history
  • Loading branch information
Emzi0767 committed Jul 22, 2020
1 parent 6c3f6ad commit 783d442
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Emzi0767.MusicTurret/Emzi0767.MusicTurret.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.5.9</Version>
<Version>1.5.10</Version>
<AssemblyVersion>$(Version).0</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<AssemblyTitle>Music Turret Discord Bot</AssemblyTitle>
Expand Down
11 changes: 9 additions & 2 deletions Emzi0767.MusicTurret/TurretBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,18 @@ private Task Discord_GuildAvailable(GuildCreateEventArgs e)

private async Task Discord_VoiceStateUpdated(VoiceStateUpdateEventArgs e)
{
var music = this.Services.GetService<MusicService>();
var gmd = await music.GetOrCreateDataAsync(e.Guild);
if (e.After.Channel == null && e.User == this.Discord.CurrentUser)
{
await gmd.StopAsync();
await gmd.DestroyPlayerAsync();
return;
}

if (e.User == this.Discord.CurrentUser)
return;

var music = this.Services.GetService<MusicService>();
var gmd = await music.GetOrCreateDataAsync(e.Guild);
var chn = gmd.Channel;
if (chn == null || chn != e.Before.Channel)
return;
Expand Down

0 comments on commit 783d442

Please sign in to comment.