27 lines
871 B
TypeScript
27 lines
871 B
TypeScript
import { EmbedBuilder, Message } from "discord.js";
|
||
|
||
export default function awardEmbed(
|
||
message: Message,
|
||
score: number,
|
||
): EmbedBuilder {
|
||
const reactionSummary = message.reactions.cache
|
||
.map((item) => `${item.emoji} ×${item.count}`)
|
||
.join(" · ");
|
||
|
||
return new EmbedBuilder()
|
||
.setColor(0x777777)
|
||
.setAuthor({
|
||
name: message.author?.displayName || "Unknown user",
|
||
iconURL: message.author?.avatarURL() || undefined,
|
||
})
|
||
.setDescription(message.content || null)
|
||
.setThumbnail(
|
||
message.attachments.find((attachment) => attachment.height || attachment.width)?.url ?? null,
|
||
)
|
||
.addFields({
|
||
name: `${reactionSummary} / ${score.toFixed(1)}`.slice(0, 256),
|
||
value: `${message.url} • <t:${Math.floor(message.createdTimestamp / 1000)}:f>`,
|
||
})
|
||
.setFooter({ text: `Source message: ${message.id}` });
|
||
}
|