Skip to content

Commit

Permalink
Added inactivity tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
FeroxFoxxo committed Dec 11, 2023
1 parent 7c0ea4c commit 0d81036
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 0 additions & 1 deletion backend/Music/Extensions/GetPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Lavalink4NET;
using Music.Services;
using Discord;
using Discord.Interactions;
using Lavalink4NET.DiscordNet;

namespace Music.Extensions;
Expand Down
19 changes: 15 additions & 4 deletions backend/Music/MusicModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"];

Expand All @@ -26,22 +29,30 @@ public override void AddServices(IServiceCollection services, CachedServices cac
services
.AddSingleton(new InteractiveConfig { DefaultTimeout = TimeSpan.FromMinutes(5) })
.AddSingleton<InteractiveService>()
.AddLavalink()

.AddSingleton<LyricsOptions>()
.AddSingleton<LyricsService>()
.AddSingleton<ArtworkService>()

.AddSingleton(new InactivityTrackingOptions
{
DefaultPollInterval = TimeSpan.FromMinutes(5), InactivityBehavior = PlayerInactivityBehavior.Pause, TrackingMode = InactivityTrackingMode.Any
DefaultPollInterval = TimeSpan.FromMinutes(5),
DefaultTimeout = TimeSpan.FromMinutes(5),
UseDefaultTrackers = true
})
.Configure<IdleInactivityTrackerOptions>(config => config.Timeout = TimeSpan.FromSeconds(10))
.AddInactivityTracking()
.AddSingleton<InactivityTrackingService>()

.AddSingleton<IDiscordClientWrapper, DiscordClientWrapper>(x =>
new DiscordClientWrapper(x.GetRequiredService<DiscordSocketClient>()))

.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();
}

0 comments on commit 0d81036

Please sign in to comment.