feat: modernize and harden bot deployment

This commit is contained in:
2026-08-13 18:31:06 +09:00
parent 09ccb03626
commit 061dbf0f3f
18 changed files with 698 additions and 1702 deletions
+20 -17
View File
@@ -1,24 +1,27 @@
import { EmbedBuilder, MessageReaction, PartialMessageReaction } from 'discord.js';
import { EmbedBuilder, MessageReaction, PartialMessageReaction } from "discord.js";
export default function awardEmbed(
reaction: MessageReaction | PartialMessageReaction,
score: number,
): EmbedBuilder {
const message = reaction.message;
const reactionSummary = message.reactions.cache
.map((item) => `${item.emoji} ×${item.count}`)
.join(" · ");
export default function awardEmbed(reaction: MessageReaction | PartialMessageReaction, score: number) {
function formatTime(time: Date) {
const yyyy = time.getFullYear();
const mm = time.getMonth().toString().padStart(2, '0');
const dd = time.getDate().toString().padStart(2, '0');
const hh = time.getHours().toString().padStart(2, '0');
const MM = time.getMinutes().toString().padStart(2, '0');
return `${yyyy}-${mm}-${dd} ${hh}:${MM}`;
}
return new EmbedBuilder()
.setColor(0x777777)
.setAuthor({
name: reaction.message.author?.displayName || "unknown",
iconURL: reaction.message.author?.avatarURL() || undefined,
name: message.author?.displayName || "Unknown user",
iconURL: message.author?.avatarURL() || undefined,
})
.setDescription(reaction.message.content || null)
.setThumbnail(reaction.message.attachments.filter((attachment) => !(!attachment.height && !attachment.width)).first()?.url || null)
.setDescription(message.content || null)
.setThumbnail(
message.attachments.find((attachment) => attachment.height || attachment.width)?.url ?? null,
)
.addFields({
name: `${reaction.message.reactions.cache.map((reaction) => `${reaction.emoji} x${reaction.count},`).join(' ')} / ${score.toFixed(1)}`,
value: `${reaction.message.url}${formatTime(reaction.message.createdAt)}\n-# ${reaction.message.id}`,
name: `${reactionSummary} / ${score.toFixed(1)}`.slice(0, 256),
value: `${message.url}<t:${Math.floor(message.createdTimestamp / 1000)}:f>`,
})
}
.setFooter({ text: `Source message: ${message.id}` });
}