Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
FeroxFoxxo committed Mar 29, 2024
2 parents 550cf88 + ca6c5a8 commit 5154020
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions backend/Music/Commands/Leave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class LeaveCommand : MusicCommand<LeaveCommand>
public async Task Leave()
{
await Player.StopAsync();
await Player.DisconnectAsync();

await RespondInteraction("Left this session, the queue has been cleaned");
}
Expand Down
2 changes: 1 addition & 1 deletion backend/Music/Commands/Volume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Music.Commands;

public class VolumeCommand : MusicCommand<StopCommand>
{
[SlashCommand("volume", description: "Sets the player volume (0 - 1000%)", runMode: RunMode.Async)]
[SlashCommand("volume", description: "Sets the player volume (0 - 1000%)")]
[BotChannel]
public async Task Volume(int volume = 100)
{
Expand Down
20 changes: 19 additions & 1 deletion backend/Music/Extensions/GetPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
using Music.Services;
using Discord;
using Lavalink4NET.DiscordNet;
using Lavalink4NET.Integrations.SponsorBlock;
using System.Collections.Immutable;
using System.Numerics;
using Lavalink4NET.Integrations.SponsorBlock.Extensions;

namespace Music.Extensions;

Expand All @@ -29,7 +33,21 @@ public static async ValueTask<VoteLavalinkPlayer> GetPlayerAsync(this IAudioServ
await context.Interaction.FollowupAsync("Connecting to voice channel.");

music.SetStartTimeAsCurrent(context.Guild.Id);
return await audio.GetPlayerAsync(context, music, true);

var player = await audio.GetPlayerAsync(context, music, true); ;

var categories = ImmutableArray.Create(
SegmentCategory.Intro,
SegmentCategory.Sponsor,
SegmentCategory.SelfPromotion,
SegmentCategory.OfftopicMusic
);

await player
.UpdateSponsorBlockCategoriesAsync(categories)
.ConfigureAwait(false);

return player;
}

var errorMessage = result.Status switch
Expand Down
4 changes: 4 additions & 0 deletions backend/Music/MusicModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
using Lavalink4NET.InactivityTracking;
using Lavalink4NET.InactivityTracking.Extensions;
using Lavalink4NET.InactivityTracking.Trackers.Idle;
using Lavalink4NET.Integrations.SponsorBlock.Extensions;
using Lavalink4NET.Lyrics;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System.Net;

Expand Down Expand Up @@ -54,6 +56,8 @@ public override void AddServices(IServiceCollection services, CachedServices cac
.AddLavalink();
}

public override void ConfigureModules(List<Module> modules, WebApplication app) => app.UseSponsorBlock();

public static IPAddress GetMyIp()
{
var services = new List<string>()
Expand Down

0 comments on commit 5154020

Please sign in to comment.