From 1326b91f9657d2bca1dcda171a5d7ac48830c87d Mon Sep 17 00:00:00 2001 From: FeroxFoxxo Date: Tue, 12 Dec 2023 05:26:09 +1300 Subject: [PATCH] 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();