mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
- Reworked embed builder
- Use IEmbedBuilderService to create embed builders - Wrapped embed builder and using IEmbedBuilder
This commit is contained in:
@@ -112,7 +112,7 @@ namespace NadekoBot.Modules.Music
|
||||
|
||||
try
|
||||
{
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithAuthor(GetText("queued_song") + " #" + (index + 1), MusicIconUrl)
|
||||
.WithDescription($"{trackInfo.PrettyName()}\n{GetText("queue")} ")
|
||||
@@ -281,7 +281,7 @@ namespace NadekoBot.Modules.Music
|
||||
return;
|
||||
}
|
||||
|
||||
EmbedBuilder printAction(int curPage)
|
||||
IEmbedBuilder printAction(int curPage)
|
||||
{
|
||||
string desc = string.Empty;
|
||||
var current = mp.GetCurrentTrack(out var currentIndex);
|
||||
@@ -328,7 +328,7 @@ namespace NadekoBot.Modules.Music
|
||||
if (!string.IsNullOrWhiteSpace(add))
|
||||
desc = add + "\n" + desc;
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithAuthor(GetText("player_queue", curPage + 1, (tracks.Count / LQ_ITEMS_PER_PAGE) + 1),
|
||||
MusicIconUrl)
|
||||
.WithDescription(desc)
|
||||
@@ -365,7 +365,7 @@ namespace NadekoBot.Modules.Music
|
||||
.Select((x, i) => $"`{i + 1}.`\n\t{Format.Bold(x.Title)}\n\t{x.Url}")
|
||||
.JoinWith('\n');
|
||||
|
||||
var msg = await ctx.Channel.SendConfirmAsync(resultsString);
|
||||
var msg = await SendConfirmAsync(resultsString);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -430,7 +430,7 @@ namespace NadekoBot.Modules.Music
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithAuthor(GetText("removed_song") + " #" + (index), MusicIconUrl)
|
||||
.WithDescription(song.PrettyName())
|
||||
.WithFooter(song.PrettyInfo())
|
||||
@@ -613,12 +613,12 @@ namespace NadekoBot.Modules.Music
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithTitle(track.Title.TrimTo(65))
|
||||
.WithAuthor(GetText("song_moved"), MusicIconUrl)
|
||||
.AddField(GetText("from_position"), $"#{from + 1}", true)
|
||||
.AddField(GetText("to_position"), $"#{to + 1}", true)
|
||||
.WithColor(Bot.OkColor);
|
||||
.WithOkColor();
|
||||
|
||||
if (Uri.IsWellFormedUriString(track.Url, UriKind.Absolute))
|
||||
embed.WithUrl(track.Url);
|
||||
@@ -701,7 +701,7 @@ namespace NadekoBot.Modules.Music
|
||||
if (currentTrack is null)
|
||||
return;
|
||||
|
||||
var embed = new EmbedBuilder().WithOkColor()
|
||||
var embed = _eb.Create().WithOkColor()
|
||||
.WithAuthor(GetText("now_playing"), MusicIconUrl)
|
||||
.WithDescription(currentTrack.PrettyName())
|
||||
.WithThumbnailUrl(currentTrack.Thumbnail)
|
||||
|
@@ -61,11 +61,13 @@ namespace NadekoBot.Modules.Music
|
||||
playlists = uow.MusicPlaylists.GetPlaylistsOnPage(num);
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb
|
||||
.Create(ctx)
|
||||
.WithAuthor(GetText("playlists_page", num), MusicIconUrl)
|
||||
.WithDescription(string.Join("\n", playlists.Select(r =>
|
||||
GetText("playlists", r.Id, r.Name, r.Author, r.Songs.Count))))
|
||||
.WithOkColor();
|
||||
|
||||
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -122,7 +124,7 @@ namespace NadekoBot.Modules.Music
|
||||
.Skip(cur * 20)
|
||||
.Take(20)
|
||||
.Select(x => $"`{++i}.` [{x.Title.TrimTo(45)}]({x.Query}) `{x.Provider}`"));
|
||||
return new EmbedBuilder()
|
||||
return _eb.Create()
|
||||
.WithTitle($"\"{mpl.Name}\" by {mpl.Author}")
|
||||
.WithOkColor()
|
||||
.WithDescription(str);
|
||||
@@ -162,7 +164,7 @@ namespace NadekoBot.Modules.Music
|
||||
await uow.SaveChangesAsync();
|
||||
}
|
||||
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
await ctx.Channel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("playlist_saved"))
|
||||
.AddField(GetText("name"), name)
|
||||
|
@@ -29,7 +29,7 @@ namespace NadekoBot.Modules.Music.Services
|
||||
Task<int> EnqueueYoutubePlaylistAsync(IMusicPlayer mp, string playlistId, string queuer);
|
||||
Task EnqueueDirectoryAsync(IMusicPlayer mp, string dirPath, string queuer);
|
||||
Task<int> EnqueueSoundcloudPlaylistAsync(IMusicPlayer mp, string playlist, string queuer);
|
||||
Task<IUserMessage?> SendToOutputAsync(ulong guildId, EmbedBuilder embed);
|
||||
Task<IUserMessage?> SendToOutputAsync(ulong guildId, IEmbedBuilder embed);
|
||||
Task<bool> PlayAsync(ulong guildId, ulong voiceChannelId);
|
||||
Task<IList<(string Title, string Url)>> SearchVideosAsync(string query);
|
||||
Task<bool> SetMusicChannelAsync(ulong guildId, ulong? channelId);
|
||||
|
@@ -29,6 +29,7 @@ namespace NadekoBot.Modules.Music.Services
|
||||
private readonly IBotStrings _strings;
|
||||
private readonly IGoogleApiService _googleApiService;
|
||||
private readonly YtLoader _ytLoader;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
|
||||
private readonly ConcurrentDictionary<ulong, IMusicPlayer> _players;
|
||||
private readonly ConcurrentDictionary<ulong, (ITextChannel Default, ITextChannel? Override)> _outputChannels;
|
||||
@@ -36,7 +37,8 @@ namespace NadekoBot.Modules.Music.Services
|
||||
|
||||
public MusicService(AyuVoiceStateService voiceStateService, ITrackResolveProvider trackResolveProvider,
|
||||
DbService db, IYoutubeResolver ytResolver, ILocalTrackResolver localResolver, ISoundcloudResolver scResolver,
|
||||
DiscordSocketClient client, IBotStrings strings, IGoogleApiService googleApiService, YtLoader ytLoader)
|
||||
DiscordSocketClient client, IBotStrings strings, IGoogleApiService googleApiService, YtLoader ytLoader,
|
||||
IEmbedBuilderService eb)
|
||||
{
|
||||
_voiceStateService = voiceStateService;
|
||||
_trackResolveProvider = trackResolveProvider;
|
||||
@@ -48,6 +50,7 @@ namespace NadekoBot.Modules.Music.Services
|
||||
_strings = strings;
|
||||
_googleApiService = googleApiService;
|
||||
_ytLoader = ytLoader;
|
||||
_eb = eb;
|
||||
|
||||
_players = new ConcurrentDictionary<ulong, IMusicPlayer>();
|
||||
_outputChannels = new ConcurrentDictionary<ulong, (ITextChannel, ITextChannel?)>();
|
||||
@@ -189,7 +192,7 @@ namespace NadekoBot.Modules.Music.Services
|
||||
return mp;
|
||||
}
|
||||
|
||||
public Task<IUserMessage?> SendToOutputAsync(ulong guildId, EmbedBuilder embed)
|
||||
public Task<IUserMessage?> SendToOutputAsync(ulong guildId, IEmbedBuilder embed)
|
||||
{
|
||||
if (_outputChannels.TryGetValue(guildId, out var chan))
|
||||
return (chan.Default ?? chan.Override).EmbedAsync(embed);
|
||||
@@ -203,7 +206,7 @@ namespace NadekoBot.Modules.Music.Services
|
||||
return async (mp, trackInfo) =>
|
||||
{
|
||||
_ = lastFinishedMessage?.DeleteAsync();
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithAuthor(GetText(guildId, "finished_song"), Music.MusicIconUrl)
|
||||
.WithDescription(trackInfo.PrettyName())
|
||||
@@ -219,7 +222,7 @@ namespace NadekoBot.Modules.Music.Services
|
||||
return async (mp, trackInfo, index) =>
|
||||
{
|
||||
_ = lastPlayingMessage?.DeleteAsync();
|
||||
var embed = new EmbedBuilder().WithOkColor()
|
||||
var embed = _eb.Create().WithOkColor()
|
||||
.WithAuthor(GetText(guildId, "playing_song", index + 1), Music.MusicIconUrl)
|
||||
.WithDescription(trackInfo.PrettyName())
|
||||
.WithFooter($"{mp.PrettyVolume()} | {trackInfo.PrettyInfo()}");
|
||||
|
Reference in New Issue
Block a user