From 0d810367d9ac3854dd5d9eb1cc35d1062cfe61b3 Mon Sep 17 00:00:00 2001 From: "feroxfoxxo@gmail.com" Date: Mon, 11 Dec 2023 23:16:07 +1300 Subject: [PATCH] Added inactivity tracking --- backend/Music/Extensions/GetPlayer.cs | 1 - backend/Music/MusicModule.cs | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/Music/Extensions/GetPlayer.cs b/backend/Music/Extensions/GetPlayer.cs index 7efd6b195..a5be5e944 100644 --- a/backend/Music/Extensions/GetPlayer.cs +++ b/backend/Music/Extensions/GetPlayer.cs @@ -4,7 +4,6 @@ using Lavalink4NET; using Music.Services; using Discord; -using Discord.Interactions; using Lavalink4NET.DiscordNet; namespace Music.Extensions; diff --git a/backend/Music/MusicModule.cs b/backend/Music/MusicModule.cs index 1db5654a2..671d73205 100644 --- a/backend/Music/MusicModule.cs +++ b/backend/Music/MusicModule.cs @@ -8,6 +8,8 @@ using Lavalink4NET.DiscordNet; using Lavalink4NET.Extensions; using Lavalink4NET.InactivityTracking; +using Lavalink4NET.InactivityTracking.Extensions; +using Lavalink4NET.InactivityTracking.Trackers.Idle; using Lavalink4NET.Lyrics; using Lavalink4NET.Tracking; using Microsoft.Extensions.DependencyInjection; @@ -18,6 +20,7 @@ public class MusicModule : Module { public const string Host = "lavalink.usfurries.com"; public const int Port = 2333; + public const string Pass = "youshallnotpass"; public override string[] Contributors { get; } = ["Swyreee", "Ferox"]; @@ -26,22 +29,30 @@ public override void AddServices(IServiceCollection services, CachedServices cac services .AddSingleton(new InteractiveConfig { DefaultTimeout = TimeSpan.FromMinutes(5) }) .AddSingleton() - .AddLavalink() + .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton(new InactivityTrackingOptions { - DefaultPollInterval = TimeSpan.FromMinutes(5), InactivityBehavior = PlayerInactivityBehavior.Pause, TrackingMode = InactivityTrackingMode.Any + DefaultPollInterval = TimeSpan.FromMinutes(5), + DefaultTimeout = TimeSpan.FromMinutes(5), + UseDefaultTrackers = true }) + .Configure(config => config.Timeout = TimeSpan.FromSeconds(10)) + .AddInactivityTracking() .AddSingleton() + .AddSingleton(x => new DiscordClientWrapper(x.GetRequiredService())) + .ConfigureLavalink(config => { config.BaseAddress = new Uri($"http://{Host}:{Port}"); config.WebSocketUri = new Uri($"ws://{Host}:{Port}/v4/websocket"); config.ReadyTimeout = TimeSpan.FromSeconds(10); - config.Passphrase = "youshallnotpass"; - }); + config.Passphrase = Pass; + }) + .AddLavalink(); }