Fix BasicTrackInfo having wrong TrackID
Add Character Limit to TrackList Method to fix tracklists being to big for messages
This commit is contained in:
parent
8720bf9f88
commit
021528afd1
TomatenMusic/Models
TomatenMusicCore
Prompt
Implementation
Model
Option
Util
@ -27,7 +27,7 @@ namespace TomatenMusic_Api.Models
|
|||||||
|
|
||||||
Name = track.Title;
|
Name = track.Title;
|
||||||
Platform = ctx.SpotifyIdentifier == null ? TrackPlatform.YOUTUBE : TrackPlatform.SPOTIFY;
|
Platform = ctx.SpotifyIdentifier == null ? TrackPlatform.YOUTUBE : TrackPlatform.SPOTIFY;
|
||||||
YoutubeId = track.Identifier;
|
YoutubeId = track.TrackIdentifier;
|
||||||
SpotifyId = ctx.SpotifyIdentifier;
|
SpotifyId = ctx.SpotifyIdentifier;
|
||||||
URL = ctx.YoutubeUri;
|
URL = ctx.YoutubeUri;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace TomatenMusic.Prompt.Implementation
|
|||||||
DiscordEmbedBuilder builder = new DiscordEmbedBuilder()
|
DiscordEmbedBuilder builder = new DiscordEmbedBuilder()
|
||||||
.WithTitle("What do you want to do with these Tracks?");
|
.WithTitle("What do you want to do with these Tracks?");
|
||||||
|
|
||||||
builder.WithDescription(Common.TrackListString(Tracks));
|
builder.WithDescription(Common.TrackListString(Tracks, 1000));
|
||||||
|
|
||||||
return Task.FromResult(new DiscordMessageBuilder().WithEmbed(builder.Build()));
|
return Task.FromResult(new DiscordMessageBuilder().WithEmbed(builder.Build()));
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ namespace TomatenMusic.Prompt.Implementation
|
|||||||
{
|
{
|
||||||
|
|
||||||
builder.WithTitle(Title);
|
builder.WithTitle(Title);
|
||||||
builder.WithDescription(Common.TrackListString(PageManager.GetPage(CurrentPage)));
|
builder.WithDescription(Common.TrackListString(PageManager.GetPage(CurrentPage), 4000));
|
||||||
List<DiscordEmbed> embeds = new List<DiscordEmbed>();
|
List<DiscordEmbed> embeds = new List<DiscordEmbed>();
|
||||||
embeds.Add(builder.Build());
|
embeds.Add(builder.Build());
|
||||||
|
|
||||||
|
@ -164,6 +164,7 @@ namespace TomatenMusic.Prompt.Model
|
|||||||
_client = client.GetShard((ulong)interaction.GuildId);
|
_client = client.GetShard((ulong)interaction.GuildId);
|
||||||
|
|
||||||
_client.ComponentInteractionCreated += Discord_ComponentInteractionCreated;
|
_client.ComponentInteractionCreated += Discord_ComponentInteractionCreated;
|
||||||
|
|
||||||
ActivePrompts.Add(this);
|
ActivePrompts.Add(this);
|
||||||
AddGuids();
|
AddGuids();
|
||||||
DiscordWebhookBuilder builder = await GetWebhookMessageAsync();
|
DiscordWebhookBuilder builder = await GetWebhookMessageAsync();
|
||||||
|
@ -19,8 +19,5 @@ namespace TomatenMusic.Prompt.Option
|
|||||||
public Func<IPromptOption, Task<IPromptOption>> UpdateMethod { get; set; }
|
public Func<IPromptOption, Task<IPromptOption>> UpdateMethod { get; set; }
|
||||||
public Func<DSharpPlus.EventArgs.ComponentInteractionCreateEventArgs, DiscordClient, IPromptOption, Task> Run { get; set; }
|
public Func<DSharpPlus.EventArgs.ComponentInteractionCreateEventArgs, DiscordClient, IPromptOption, Task> Run { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ namespace TomatenMusic.Util
|
|||||||
builder.WithAuthor(playlist.AuthorName, playlist.AuthorUri.ToString(), youtubePlaylist.AuthorThumbnail.ToString());
|
builder.WithAuthor(playlist.AuthorName, playlist.AuthorUri.ToString(), youtubePlaylist.AuthorThumbnail.ToString());
|
||||||
builder.WithTitle(playlist.Name);
|
builder.WithTitle(playlist.Name);
|
||||||
builder.WithUrl(playlist.Url);
|
builder.WithUrl(playlist.Url);
|
||||||
builder.WithDescription(TrackListString(playlist.Tracks));
|
builder.WithDescription(TrackListString(playlist.Tracks, 4000));
|
||||||
builder.WithImageUrl(youtubePlaylist.Thumbnail);
|
builder.WithImageUrl(youtubePlaylist.Thumbnail);
|
||||||
builder.AddField("Description", playlist.Description, false);
|
builder.AddField("Description", playlist.Description, false);
|
||||||
builder.AddField("Track Count", $"{playlist.Tracks.Count()} Tracks", true);
|
builder.AddField("Track Count", $"{playlist.Tracks.Count()} Tracks", true);
|
||||||
@ -117,7 +117,7 @@ namespace TomatenMusic.Util
|
|||||||
|
|
||||||
builder.WithTitle(playlist.Name);
|
builder.WithTitle(playlist.Name);
|
||||||
builder.WithUrl(playlist.Url);
|
builder.WithUrl(playlist.Url);
|
||||||
builder.WithDescription(TrackListString(playlist.Tracks));
|
builder.WithDescription(TrackListString(playlist.Tracks, 4000));
|
||||||
builder.AddField("Description", playlist.Description, false);
|
builder.AddField("Description", playlist.Description, false);
|
||||||
builder.AddField("Track Count", $"{playlist.Tracks.Count()} Tracks", true);
|
builder.AddField("Track Count", $"{playlist.Tracks.Count()} Tracks", true);
|
||||||
builder.AddField("Length", $"{Common.GetTimestamp(playlist.GetLength())}", true);
|
builder.AddField("Length", $"{Common.GetTimestamp(playlist.GetLength())}", true);
|
||||||
@ -136,7 +136,7 @@ namespace TomatenMusic.Util
|
|||||||
{
|
{
|
||||||
DiscordEmbedBuilder builder = new DiscordEmbedBuilder();
|
DiscordEmbedBuilder builder = new DiscordEmbedBuilder();
|
||||||
|
|
||||||
builder.WithDescription(TrackListString(player.PlayerQueue.Queue));
|
builder.WithDescription(TrackListString(player.PlayerQueue.Queue, 4000));
|
||||||
builder.WithTitle("Current Queue");
|
builder.WithTitle("Current Queue");
|
||||||
builder.WithAuthor($"{player.PlayerQueue.Queue.Count} Songs");
|
builder.WithAuthor($"{player.PlayerQueue.Queue.Count} Songs");
|
||||||
|
|
||||||
@ -154,24 +154,28 @@ namespace TomatenMusic.Util
|
|||||||
builder.AddField("Current Playlist", $"[{player.PlayerQueue.CurrentPlaylist.Name}]({player.PlayerQueue.CurrentPlaylist.Url})", true);
|
builder.AddField("Current Playlist", $"[{player.PlayerQueue.CurrentPlaylist.Name}]({player.PlayerQueue.CurrentPlaylist.Url})", true);
|
||||||
|
|
||||||
if (player.PlayerQueue.PlayedTracks.Any())
|
if (player.PlayerQueue.PlayedTracks.Any())
|
||||||
builder.AddField("History", TrackListString(player.PlayerQueue.PlayedTracks), true);
|
builder.AddField("History", TrackListString(player.PlayerQueue.PlayedTracks, 1000), true);
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string TrackListString(IEnumerable<LavalinkTrack> tracks)
|
public static string TrackListString(IEnumerable<LavalinkTrack> tracks, int maxCharacters)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
string lastString = " ";
|
||||||
int count = 1;
|
int count = 1;
|
||||||
foreach (LavalinkTrack track in tracks)
|
foreach (LavalinkTrack track in tracks)
|
||||||
{
|
{
|
||||||
FullTrackContext context = (FullTrackContext)track.Context;
|
if (builder.ToString().Length > maxCharacters)
|
||||||
if (count > 10)
|
|
||||||
{
|
{
|
||||||
builder.Append(String.Format("***And {0} more...***", tracks.Count() - 10));
|
builder = new StringBuilder(lastString);
|
||||||
|
builder.Append(String.Format("***And {0} more...***", tracks.Count() - count));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FullTrackContext context = (FullTrackContext)track.Context;
|
||||||
|
|
||||||
|
lastString = builder.ToString();
|
||||||
builder.Append(count).Append(": ").Append($"[{track.Title}]({context.YoutubeUri})").Append(" [").Append(Common.GetTimestamp(track.Duration)).Append("] | ");
|
builder.Append(count).Append(": ").Append($"[{track.Title}]({context.YoutubeUri})").Append(" [").Append(Common.GetTimestamp(track.Duration)).Append("] | ");
|
||||||
builder.Append($"[{track.Author}]({context.YoutubeAuthorUri})").Append("\n\n");
|
builder.Append($"[{track.Author}]({context.YoutubeAuthorUri})").Append("\n\n");
|
||||||
count++;
|
count++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user