From 5ab52dd129749e52a8b7962bb45fe7f01c7bb3e5 Mon Sep 17 00:00:00 2001 From: FeroxFoxxo Date: Tue, 12 Dec 2023 05:07:14 +1300 Subject: [PATCH 1/4] Turned domain to localhost --- backend/Music/MusicModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/Music/MusicModule.cs b/backend/Music/MusicModule.cs index 8b1465f52..ef19adc39 100644 --- a/backend/Music/MusicModule.cs +++ b/backend/Music/MusicModule.cs @@ -18,7 +18,7 @@ namespace Music; public class MusicModule : Module { - public const string Host = "lavalink.usfurries.com"; + public const string Host = "localhost"; public const int Port = 2333; public const string Pass = "youshallnotpass"; From d0f2a33e1fc996610381bc49627f905c658747df Mon Sep 17 00:00:00 2001 From: FeroxFoxxo Date: Tue, 12 Dec 2023 05:18:29 +1300 Subject: [PATCH 2/4] Use public ip instead of local host --- backend/Music/Commands/PlayPlaylist.cs | 1 - backend/Music/Commands/PlayStream.cs | 3 -- backend/Music/MusicModule.cs | 38 ++++++++++++++++++++------ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/backend/Music/Commands/PlayPlaylist.cs b/backend/Music/Commands/PlayPlaylist.cs index d84dccd9f..9a6c74342 100644 --- a/backend/Music/Commands/PlayPlaylist.cs +++ b/backend/Music/Commands/PlayPlaylist.cs @@ -3,7 +3,6 @@ using Discord.Interactions; using Fergun.Interactive; using Lavalink4NET.Players; -using Lavalink4NET.Rest.Entities.Tracks; using Lavalink4NET.Tracks; using Music.Abstractions; using Music.Enums; diff --git a/backend/Music/Commands/PlayStream.cs b/backend/Music/Commands/PlayStream.cs index 04190f920..9b6b78f92 100644 --- a/backend/Music/Commands/PlayStream.cs +++ b/backend/Music/Commands/PlayStream.cs @@ -1,11 +1,8 @@ using Bot.Attributes; using Discord.Interactions; -using Lavalink4NET.Rest.Entities.Tracks; -using Microsoft.AspNetCore.Components.Routing; using Music.Abstractions; using Music.Enums; using Music.Extensions; -using System.Numerics; namespace Music.Commands; diff --git a/backend/Music/MusicModule.cs b/backend/Music/MusicModule.cs index ef19adc39..9e1fef9a6 100644 --- a/backend/Music/MusicModule.cs +++ b/backend/Music/MusicModule.cs @@ -1,31 +1,30 @@ using Bot.Abstractions; using Bot.Models; using Bot.Services; -using Discord.WebSocket; using Fergun.Interactive; using Lavalink4NET.Artwork; -using Lavalink4NET.Clients; -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; +using System.Net; namespace Music; public class MusicModule : Module { - public const string Host = "localhost"; public const int Port = 2333; public const string Pass = "youshallnotpass"; public override string[] Contributors { get; } = ["Swyreee", "Ferox"]; public override void AddServices(IServiceCollection services, CachedServices cachedServices, - AppSettings appSettings) => + AppSettings appSettings) + { + var host = GetMyIp().ToString(); + services .AddSingleton(new InteractiveConfig { DefaultTimeout = TimeSpan.FromMinutes(5) }) .AddSingleton() @@ -47,10 +46,33 @@ public override void AddServices(IServiceCollection services, CachedServices cac .ConfigureLavalink(config => { - config.BaseAddress = new Uri($"http://{Host}:{Port}"); - config.WebSocketUri = new Uri($"ws://{Host}:{Port}/v4/websocket"); + config.BaseAddress = new Uri($"http://{host}:{Port}"); + config.WebSocketUri = new Uri($"ws://{host}:{Port}/v4/websocket"); config.ReadyTimeout = TimeSpan.FromSeconds(10); config.Passphrase = Pass; }) .AddLavalink(); + } + + public static IPAddress GetMyIp() + { + var services = new List() + { + "https://ipv4.icanhazip.com", + "https://api.ipify.org", + "https://ipinfo.io/ip", + "https://checkip.amazonaws.com", + "https://wtfismyip.com/text", + "http://icanhazip.com" + }; + + using var webclient = new HttpClient(); + + foreach (var service in services) + try { + return IPAddress.Parse(webclient.GetStringAsync(service).Result); + } catch { } + + return null; + } } From 1326b91f9657d2bca1dcda171a5d7ac48830c87d Mon Sep 17 00:00:00 2001 From: FeroxFoxxo Date: Tue, 12 Dec 2023 05:26:09 +1300 Subject: [PATCH 3/4] Default to YouTube streaming --- backend/Music/Commands/Play.cs | 6 +++++- backend/Music/Commands/PlayStream.cs | 2 +- .../Punishments/Controllers/ModCaseCommentsController.cs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/Music/Commands/Play.cs b/backend/Music/Commands/Play.cs index f3062910a..2f4602cd0 100644 --- a/backend/Music/Commands/Play.cs +++ b/backend/Music/Commands/Play.cs @@ -4,6 +4,7 @@ using Discord.Interactions; using Discord.WebSocket; using Lavalink4NET.Players; +using Lavalink4NET.Rest.Entities.Tracks; using Lavalink4NET.Tracks; using Music.Abstractions; using Music.Enums; @@ -40,11 +41,14 @@ public async Task Play( { if (query != null) { + if (source == MusicSource.Default) + searchMode = TrackSearchMode.YouTube; + var tracks = await Audio.Tracks.LoadTracksAsync(query, searchMode); var lavalinkTracks = tracks.Tracks.ToList(); - if (!lavalinkTracks.Any()) + if (lavalinkTracks.Count == 0) { await RespondInteraction("Unable to get tracks. If this was a link to a stream or playlist, please use `/music play-stream` or `play-playlist`."); diff --git a/backend/Music/Commands/PlayStream.cs b/backend/Music/Commands/PlayStream.cs index 9b6b78f92..4cd8e117d 100644 --- a/backend/Music/Commands/PlayStream.cs +++ b/backend/Music/Commands/PlayStream.cs @@ -16,7 +16,7 @@ public async Task PlayStream( { if (!Uri.IsWellFormedUriString(streamUrl, UriKind.Absolute)) { - await RespondInteraction("I need a valid stream URL to function"); + await RespondInteraction("You need to provide a valid URL"); return; } diff --git a/backend/Punishments/Controllers/ModCaseCommentsController.cs b/backend/Punishments/Controllers/ModCaseCommentsController.cs index e2d1dbe7c..1ce143b3e 100644 --- a/backend/Punishments/Controllers/ModCaseCommentsController.cs +++ b/backend/Punishments/Controllers/ModCaseCommentsController.cs @@ -31,7 +31,7 @@ public async Task CreateItem([FromRoute] ulong guildId, [FromRout // Suspects can only comment if last comment was not by him. if (!await identity.HasPermission(DiscordPermission.Moderator, guildId)) - if (modCase.Comments.Any()) + if (modCase.Comments.Count != 0) if (modCase.Comments.Last().UserId == currentUser.Id) throw new AlreadyCommentedException(); From 2224277d712c5db57da6a3d4377ce6b10677022b Mon Sep 17 00:00:00 2001 From: FeroxFoxxo Date: Fri, 22 Dec 2023 03:15:04 +1300 Subject: [PATCH 4/4] Simplified mod permissions --- backend/PrivateVCs/Commands/CreateVc.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/backend/PrivateVCs/Commands/CreateVc.cs b/backend/PrivateVCs/Commands/CreateVc.cs index 8f96da513..7e8423d3d 100644 --- a/backend/PrivateVCs/Commands/CreateVc.cs +++ b/backend/PrivateVCs/Commands/CreateVc.cs @@ -158,16 +158,8 @@ await newChannel.AddPermissionOverwriteAsync(role, { await newChannel.AddPermissionOverwriteAsync(staffRole, OverwritePermissions.InheritAll.Modify( - speak: PermValue.Allow, - useVoiceActivation: PermValue.Allow, - stream: PermValue.Allow, - sendMessages: PermValue.Allow, - readMessageHistory: PermValue.Allow, - useExternalEmojis: PermValue.Allow, - addReactions: PermValue.Allow, - - manageChannel: PermValue.Allow, viewChannel: PermValue.Allow, + manageChannel: PermValue.Allow, connect: PermValue.Allow, muteMembers: PermValue.Allow, deafenMembers: PermValue.Allow,