Skip to content

Commit 56232d0

Browse files
authored
Merge pull request angelobreuer#19 from angelobreuer/angelobreuer-patch-3
Release Version v1.4.6
2 parents ca4ec22 + 3935d52 commit 56232d0

25 files changed

+725
-87
lines changed

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ deploy:
1818

1919
# GitHub Release Deployment
2020
- provider: GitHub
21-
tag: v1.4.5
21+
tag: v1.4.6
2222
description: 'Automated AppVeyor deployment'
2323
auth_token:
2424
secure: MgLx/AxMRG7E0GkPw36xBBD81pAD2Qqm5pBR3UsUVDJNzx8Fm2p8rOIJQ8PCJ7pC

src/Lavalink4NET.DSharpPlus/DSharpUtil.cs

+8-7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace Lavalink4NET.DSharpPlus
2929
{
3030
using System.Reflection;
3131
using global::DSharpPlus;
32+
using global::DSharpPlus.Entities;
3233
using global::DSharpPlus.EventArgs;
3334
using global::DSharpPlus.Net.WebSocket;
3435

@@ -38,10 +39,10 @@ namespace Lavalink4NET.DSharpPlus
3839
public static class DSharpUtil
3940
{
4041
/// <summary>
41-
/// The internal "SessionId" property info in <see cref="VoiceStateUpdateEventArgs"/>.
42+
/// The internal "SessionId" property info in <see cref="DiscordVoiceState"/>.
4243
/// </summary>
43-
// https://github.com/DSharpPlus/DSharpPlus/blob/master/DSharpPlus/EventArgs/VoiceStateUpdateEventArgs.cs#L38
44-
private static readonly PropertyInfo _sessionIdProperty = typeof(VoiceStateUpdateEventArgs)
44+
// https://github.com/DSharpPlus/DSharpPlus/blob/master/DSharpPlus/Entities/DiscordVoiceState.cs#L70
45+
private static readonly PropertyInfo _sessionIdProperty = typeof(DiscordVoiceState)
4546
.GetProperty("SessionId", BindingFlags.NonPublic | BindingFlags.Instance);
4647

4748
/// <summary>
@@ -59,12 +60,12 @@ public static class DSharpUtil
5960
.GetField("_webSocketClient", BindingFlags.NonPublic | BindingFlags.Instance);
6061

6162
/// <summary>
62-
/// Gets the internal "SessionId" property value of the specified <paramref name="voiceStateUpdateEventArgs"/>.
63+
/// Gets the internal "SessionId" property value of the specified <paramref name="voiceState"/>.
6364
/// </summary>
64-
/// <param name="voiceStateUpdateEventArgs">the instance</param>
65+
/// <param name="voiceState">the instance</param>
6566
/// <returns>the "SessionId" value</returns>
66-
public static string GetSessionId(this VoiceStateUpdateEventArgs voiceStateUpdateEventArgs)
67-
=> (string)_sessionIdProperty.GetValue(voiceStateUpdateEventArgs);
67+
public static string GetSessionId(this DiscordVoiceState voiceState)
68+
=> (string)_sessionIdProperty.GetValue(voiceState);
6869

6970
/// <summary>
7071
/// Gets the "VoiceToken" property value of the specified <paramref name="voiceServerUpdateEventArgs"/>.

src/Lavalink4NET.DSharpPlus/DiscordClientWrapper.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public async Task InitializeAsync()
115115
var startTime = DateTimeOffset.UtcNow;
116116

117117
// await until current user arrived
118-
while (_client.CurrentUser == null)
118+
while (_client.CurrentUser is null)
119119
{
120120
await Task.Delay(10);
121121

@@ -170,12 +170,16 @@ private Task OnVoiceServerUpdated(VoiceServerUpdateEventArgs voiceServer)
170170
/// <returns>a task that represents the asynchronous operation</returns>
171171
private Task OnVoiceStateUpdated(global::DSharpPlus.EventArgs.VoiceStateUpdateEventArgs eventArgs)
172172
{
173-
var sessionId = eventArgs.GetSessionId();
174-
var guildId = eventArgs.Before?.Channel?.Guild?.Id ?? eventArgs.After.Channel.Guild.Id;
175-
var oldVoiceState = new VoiceState(eventArgs.Before?.Channel?.Id, guildId, sessionId);
176-
var voiceState = new VoiceState(eventArgs.After.Channel?.Id, guildId, sessionId);
177-
var args = new Events.VoiceStateUpdateEventArgs(eventArgs.User.Id, voiceState, oldVoiceState);
178-
return VoiceStateUpdated.InvokeAsync(this, args);
173+
// create voice states
174+
var oldVoiceState = eventArgs.Before?.Channel is null ? null : new VoiceState(
175+
eventArgs.Before.Channel.Id, eventArgs.Before.Guild.Id, eventArgs.Before.GetSessionId());
176+
177+
var voiceState = eventArgs.After?.Channel is null ? null : new VoiceState(
178+
eventArgs.After.Channel.Id, eventArgs.After.Guild.Id, eventArgs.After.GetSessionId());
179+
180+
// invoke event
181+
return VoiceStateUpdated.InvokeAsync(this,
182+
new Events.VoiceStateUpdateEventArgs(eventArgs.User.Id, voiceState, oldVoiceState));
179183
}
180184
}
181185
}

src/Lavalink4NET.DSharpPlus/Lavalink4NET.DSharpPlus.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<Company>Angelo Breuer</Company>
1717
<Copyright>Angelo Breuer</Copyright>
1818
<Product>Lavalink4NET</Product>
19-
<Version>1.4.5</Version>
19+
<Version>1.4.6</Version>
2020
<Description>
2121
A Lavalink wrapper for playing music using a discord bot.
2222
Integration with DSharpPlus Library.

src/Lavalink4NET.Discord_NET/DiscordClientWrapper.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
namespace Lavalink4NET.Discord_NET
28+
namespace Lavalink4NET.DiscordNet
2929
{
3030
using System;
3131
using System.Collections.Generic;
@@ -157,7 +157,7 @@ public async Task InitializeAsync()
157157
var startTime = DateTimeOffset.UtcNow;
158158

159159
// await until current user arrived
160-
while (_baseSocketClient.CurrentUser == null)
160+
while (_baseSocketClient.CurrentUser is null)
161161
{
162162
await Task.Delay(10);
163163

@@ -205,11 +205,15 @@ private Task OnVoiceServerUpdated(SocketVoiceServer voiceServer)
205205

206206
private Task OnVoiceStateUpdated(SocketUser user, SocketVoiceState oldSocketVoiceState, SocketVoiceState socketVoiceState)
207207
{
208-
var guildId = socketVoiceState.VoiceChannel?.Guild?.Id ?? oldSocketVoiceState.VoiceChannel.Guild.Id;
209-
var oldVoiceState = new VoiceState(oldSocketVoiceState.VoiceChannel?.Id, guildId, oldSocketVoiceState.VoiceSessionId);
210-
var voiceState = new VoiceState(socketVoiceState.VoiceChannel?.Id, guildId, socketVoiceState.VoiceSessionId);
211-
var args = new VoiceStateUpdateEventArgs(user.Id, voiceState, oldVoiceState);
212-
return VoiceStateUpdated.InvokeAsync(this, args);
208+
// create voice states
209+
var oldVoiceState = oldSocketVoiceState.VoiceChannel is null ? null : new VoiceState(
210+
oldSocketVoiceState.VoiceChannel.Id, oldSocketVoiceState.VoiceChannel.Guild.Id, oldSocketVoiceState.VoiceSessionId);
211+
212+
var voiceState = socketVoiceState.VoiceChannel is null ? null : new VoiceState(
213+
socketVoiceState.VoiceChannel.Id, socketVoiceState.VoiceChannel.Guild.Id, socketVoiceState.VoiceSessionId);
214+
215+
// invoke event
216+
return VoiceStateUpdated.InvokeAsync(this, new VoiceStateUpdateEventArgs(user.Id, voiceState, oldVoiceState));
213217
}
214218
}
215219
}

src/Lavalink4NET.Discord_NET/IAudioServiceExtensions.cs

+25-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
namespace Lavalink4NET.Discord_NET
28+
namespace Lavalink4NET.DiscordNet
2929
{
3030
using System.Threading.Tasks;
3131
using Discord;
@@ -46,6 +46,15 @@ public static class IAudioServiceExtensions
4646
public static TPlayer GetPlayer<TPlayer>(this IAudioService audioService, IGuild guild) where TPlayer : LavalinkPlayer
4747
=> audioService.GetPlayer<TPlayer>(guild.Id);
4848

49+
/// <summary>
50+
/// Gets the audio player for the specified <paramref name="guild"/>.
51+
/// </summary>
52+
/// <param name="audioService">the audio service</param>
53+
/// <param name="guild">the guild to get the player for</param>
54+
/// <returns>the player for the guild</returns>
55+
public static LavalinkPlayer GetPlayer(this IAudioService audioService, IGuild guild)
56+
=> audioService.GetPlayer(guild.Id);
57+
4958
/// <summary>
5059
/// Gets a value indicating whether a player is created for the specified <paramref name="guild"/>.
5160
/// </summary>
@@ -70,5 +79,20 @@ public static bool HasPlayer(this IAudioService audioService, IGuild guild)
7079
public static Task<TPlayer> JoinAsync<TPlayer>(this IAudioService audioService, IVoiceChannel voiceChannel,
7180
bool selfDeaf = false, bool selfMute = false) where TPlayer : LavalinkPlayer
7281
=> audioService.JoinAsync<TPlayer>(voiceChannel.GuildId, voiceChannel.Id, selfDeaf, selfMute);
82+
83+
/// <summary>
84+
/// Joins the specified <paramref name="audioService"/> asynchronously.
85+
/// </summary>
86+
/// <param name="audioService">the audio service</param>
87+
/// <param name="voiceChannel">the voice channel to join</param>
88+
/// <param name="selfDeaf">a value indicating whether the bot user should be self deafened</param>
89+
/// <param name="selfMute">a value indicating whether the bot user should be self muted</param>
90+
/// <returns>
91+
/// a task that represents the asynchronous operation
92+
/// <para>the audio player</para>
93+
/// </returns>
94+
public static Task JoinAsync(this IAudioService audioService, IVoiceChannel voiceChannel,
95+
bool selfDeaf = false, bool selfMute = false)
96+
=> audioService.JoinAsync(voiceChannel.GuildId, voiceChannel.Id, selfDeaf, selfMute);
7397
}
7498
}

src/Lavalink4NET.Discord_NET/Lavalink4NET.Discord_NET.csproj src/Lavalink4NET.Discord_NET/Lavalink4NET.DiscordNet.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
<PackageReleaseNotes>Compatible with Lavalink Server 3.0</PackageReleaseNotes>
1717
<PackageTags>lavalink,lavalink-wrapper,discord,discord-music,discord-music-bot,discord.net</PackageTags>
1818
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
19-
<Version>1.4.5</Version>
19+
<Version>1.4.6</Version>
2020
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2121
<PackageIconUrl>https://imgur.com/DbTYXxY.png</PackageIconUrl>
2222
<RepositoryUrl>https://github.com/angelobreuer/Lavalink4NET</RepositoryUrl>
23+
<RootNamespace>Lavalink4NET.DiscordNet</RootNamespace>
24+
<AssemblyName>Lavalink4NET.DiscordNet</AssemblyName>
2325
</PropertyGroup>
2426

2527
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

src/Lavalink4NET.Discord_NET/Lavalink4NET.Discord_NET.xml

+43-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Lavalink4NET.MemoryCache/Lavalink4NET.MemoryCache.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<PackageProjectUrl></PackageProjectUrl>
1919
<RepositoryUrl>https://github.com/angelobreuer/Lavalink4NET</RepositoryUrl>
2020
<PackageIconUrl>https://imgur.com/DbTYXxY.png</PackageIconUrl>
21-
<Version>1.4.5</Version>
21+
<Version>1.4.6</Version>
2222
</PropertyGroup>
2323

2424
<ItemGroup>

0 commit comments

Comments
 (0)