Skip to content

Commit a231f80

Browse files
authored
Merge pull request #10 from Smalls1652/update/refactor/embed-building
Move embed building to own method
2 parents 89e2969 + b5d1a54 commit a231f80

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

src/App/Modules/ShareMusicCommandModule/commands/HandleGetLinksFromPostAsync.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,7 @@ await FollowupAsync(
8383

8484
var linksComponentBuilder = GenerateMusicShareComponent(musicEntityItem);
8585

86-
var messageEmbed = new EmbedBuilder()
87-
.WithTitle(streamingEntityItem.Title)
88-
.WithDescription($"by {streamingEntityItem.ArtistName}")
89-
.WithColor(Color.DarkBlue)
90-
.WithImageUrl($"attachment://{streamingEntityItem.Title}.jpg")
91-
.WithFooter("(Powered by Songlink/Odesli)");
86+
var messageEmbed = GenerateEmbedBuilder(streamingEntityItem);
9287

9388
await Context.Channel.SendFileAsync(
9489
embed: messageEmbed.Build(),

src/App/Modules/ShareMusicCommandModule/commands/HandleMusicShareAsync.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,16 @@ await FollowupAsync(
7070
}
7171

7272
StreamingEntityItem streamingEntityItem = musicEntityItem.EntitiesByUniqueId![platformEntityLink.EntityUniqueId!];
73-
using var albumArtStream = await GetAlbumArtStreamAsync(streamingEntityItem);
73+
await using var albumArtStream = await GetAlbumArtStreamAsync(streamingEntityItem);
7474

7575
var linksComponentBuilder = GenerateMusicShareComponent(musicEntityItem);
7676

77-
var messageEmbed = new EmbedBuilder()
78-
.WithTitle(streamingEntityItem.Title)
79-
.WithDescription($"by {streamingEntityItem.ArtistName}")
80-
.WithColor(Color.DarkBlue)
81-
.WithImageUrl($"attachment://{streamingEntityItem.Title}.jpg")
82-
.WithFooter("(Powered by Songlink/Odesli)");
77+
var messageEmbed = GenerateEmbedBuilder(streamingEntityItem);
8378

8479
await FollowupWithFileAsync(
8580
embed: messageEmbed.Build(),
8681
fileStream: albumArtStream,
87-
fileName: $"{streamingEntityItem.Title}.jpg",
82+
fileName: $"{streamingEntityItem.Id}.jpg",
8883
components: linksComponentBuilder.Build()
8984
);
9085

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Discord;
2+
using MuzakBot.App.Models.Odesli;
3+
4+
namespace MuzakBot.App.Modules;
5+
6+
public partial class ShareMusicCommandModule
7+
{
8+
private EmbedBuilder GenerateEmbedBuilder(StreamingEntityItem streamingEntityItem)
9+
{
10+
return new EmbedBuilder()
11+
.WithTitle(streamingEntityItem.Title)
12+
.WithDescription($"by {streamingEntityItem.ArtistName}")
13+
.WithColor(Color.DarkBlue)
14+
.WithImageUrl($"attachment://{streamingEntityItem.Id}.jpg")
15+
.WithFooter("(Powered by Songlink/Odesli)");
16+
}
17+
}

0 commit comments

Comments
 (0)