- fixed not being able to play file urls

- fixed bot crashing after trying to display null value to current song embed
This commit is contained in:
Tim Müller 2022-03-20 00:02:37 +01:00
parent e6cae5f497
commit 0ab009451f
4 changed files with 17 additions and 19 deletions

@ -1,8 +1,8 @@
{ {
"TOKEN": "YOUR_BOT_TOKEN", "TOKEN": "ODQwNjQ5NjU1MTAwMjQzOTY4.YJbSAA.Y0AiiFVhKLXs4b487JvobxuVk_s",
"LavaLinkPassword": " ", "LavaLinkPassword": "SGWaldsolms9",
"SpotifyClientId": " ", "SpotifyClientId": "14b77fa47f2f492db58cbdca8f1e5d9c",
"SpotifyClientSecret": " ", "SpotifyClientSecret": "c247625f0cfe4b72a1faa01b7c5b8eea",
"YoutubeApiKey": " " "YoutubeApiKey": "AIzaSyBIcTl9JQ9jF412mX0Wfp_3Y-4a-V0SASQ"
} }

@ -41,6 +41,8 @@ namespace TomatenMusic.Music
else else
loadResult = await _audioService.LoadTracksAsync(query, SearchMode.YouTube); loadResult = await _audioService.LoadTracksAsync(query, SearchMode.YouTube);
if (uri != null && uri.AbsolutePath.Contains("."))
return await SearchAsync(uri);
if (loadResult.LoadType == TrackLoadType.LoadFailed) throw new ArgumentException("Track loading failed"); if (loadResult.LoadType == TrackLoadType.LoadFailed) throw new ArgumentException("Track loading failed");

@ -126,19 +126,14 @@ namespace TomatenMusic
{ {
Services = ServiceProvider Services = ServiceProvider
}); });
/*
slash.RegisterCommands<MusicCommands>(888493810554900491); slash.RegisterCommands<MusicCommands>(888493810554900491);
slash.RegisterCommands<PlayQueueGroup>(888493810554900491); slash.RegisterCommands<PlayQueueGroup>(888493810554900491);
slash.RegisterCommands<PlayNowGroup>(888493810554900491); slash.RegisterCommands<PlayNowGroup>(888493810554900491);
slash.RegisterCommands<MusicCommands>(835089895092387872); //slash.RegisterCommands<MusicCommands>();
slash.RegisterCommands<PlayQueueGroup>(835089895092387872); //slash.RegisterCommands<PlayQueueGroup>();
slash.RegisterCommands<PlayNowGroup>(835089895092387872); //slash.RegisterCommands<PlayNowGroup>();
*/
slash.RegisterCommands<MusicCommands>();
slash.RegisterCommands<PlayQueueGroup>();
slash.RegisterCommands<PlayNowGroup>();
await client.StartAsync(); await client.StartAsync();
client.Ready += Client_Ready; client.Ready += Client_Ready;

@ -258,17 +258,18 @@ namespace TomatenMusic.Util
FullTrackContext context = (FullTrackContext)track.Context; FullTrackContext context = (FullTrackContext)track.Context;
string progressBar = $"|{ProgressBar((int)player.Position.Position.TotalSeconds, (int)track.Duration.TotalSeconds)}|\n [{Common.GetTimestamp(player.Position.Position)}/{Common.GetTimestamp(track.Duration)}]"; string progressBar = $"|{ProgressBar((int)player.Position.Position.TotalSeconds, (int)track.Duration.TotalSeconds)}|\n [{Common.GetTimestamp(player.Position.Position)}/{Common.GetTimestamp(track.Duration)}]";
builder.WithAuthor(track.Author, context.YoutubeAuthorUri.ToString(), context.YoutubeAuthorThumbnail.ToString()); builder.WithAuthor(track.Author);
builder.WithTitle(track.Title); builder.WithTitle(track.Title);
builder.WithUrl(context.YoutubeUri); builder.WithUrl(track.Source);
builder.WithImageUrl(context.YoutubeThumbnail);
builder.WithColor(player.State == PlayerState.Paused ? DiscordColor.Orange : DiscordColor.Green); builder.WithColor(player.State == PlayerState.Paused ? DiscordColor.Orange : DiscordColor.Green);
builder.AddField("Length", Common.GetTimestamp(track.Duration), true); builder.AddField("Length", Common.GetTimestamp(track.Duration), true);
builder.AddField("Loop", player.PlayerQueue.LoopType.ToString(), true); builder.AddField("Loop", player.PlayerQueue.LoopType.ToString(), true);
builder.AddField("Progress", progressBar, true); builder.AddField("Progress", progressBar, true);
if (!context.IsFile) if (!context.IsFile)
{ {
builder.WithAuthor(track.Author, context.YoutubeAuthorUri.ToString(), context.YoutubeAuthorThumbnail.ToString());
builder.WithImageUrl(context.YoutubeThumbnail);
builder.AddField("Views", $"{context.YoutubeViews:N0} Views", true); builder.AddField("Views", $"{context.YoutubeViews:N0} Views", true);
builder.AddField("Rating", $"{context.YoutubeLikes:N0} 👍", true); builder.AddField("Rating", $"{context.YoutubeLikes:N0} 👍", true);
builder.AddField("Upload Date", $"{context.YoutubeUploadDate.ToString("dd. MMMM, yyyy")}", true); builder.AddField("Upload Date", $"{context.YoutubeUploadDate.ToString("dd. MMMM, yyyy")}", true);