Skip to content

Commit 13bb5c7

Browse files
committed
support attachments in starboard
1 parent 6ebb887 commit 13bb5c7

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

Boolean/EventHandlers.cs

+22-21
Original file line numberDiff line numberDiff line change
@@ -157,31 +157,32 @@ private async Task HandleExistingStarReaction(DataContext db, IUserMessage messa
157157
return;
158158
}
159159

160+
// Send to starboard channel as it has reached the minimum stars threshold
161+
160162
var starboardChannel = await client.GetChannelAsync(dbStarboardChannel.Snowflake) as ITextChannel;
161163
var embed = new EmbedBuilder
162164
{
163-
Title = "Message Link",
164-
ThumbnailUrl = message.Author.GetAvatarUrl(),
165165
Color = EmbedColors.Normal,
166-
Fields = [
167-
new EmbedFieldBuilder
168-
{
169-
Name = "Author",
170-
Value = message.Author.Username,
171-
IsInline = true,
172-
},
173-
174-
new EmbedFieldBuilder
175-
{
176-
Name = "Message",
177-
Value = message.Content,
178-
IsInline = true,
179-
},
180-
],
181-
Url = message.GetJumpUrl(),
182-
};
183-
184-
await starboardChannel.SendMessageAsync(embed: embed.Build());
166+
Description = $"{message.Content}\n\n[Message Link]({message.GetJumpUrl()})",
167+
ImageUrl = message.Attachments.FirstOrDefault()?.Url,
168+
}.WithAuthor(message.Author);
169+
170+
// Add attachments
171+
var attachments = message.Attachments.Skip(1);
172+
var attachmentsLength = attachments.Count();
173+
174+
Embed[] embeds = new Embed[attachmentsLength + 1];
175+
embeds[0] = embed.Build();
176+
177+
for (int i = 0; i < attachmentsLength; i++) {
178+
embeds[i + 1] = new EmbedBuilder
179+
{
180+
ImageUrl = attachments.ElementAt(i).Url,
181+
Color = EmbedColors.Normal,
182+
}.Build();
183+
}
184+
185+
await starboardChannel.SendMessageAsync(embeds: embeds);
185186

186187
starReaction.IsOnStarboard = true;
187188
await db.SaveChangesAsync();

0 commit comments

Comments
 (0)