Finish preliminary rework, ready to test

This commit is contained in:
Dark 2021-06-02 04:07:50 +02:00
parent 57893e7f76
commit d0a1beb809
No known key found for this signature in database
GPG key ID: 2CD6ACB6B0A87B8A
177 changed files with 854 additions and 707 deletions

View file

@ -1,6 +1,7 @@
import { EmbedWith, EMPTY_CHAR, messageLink } from "../../../utils";
import path from "path";
import { Message, GuildChannel } from "discord.js";
const imageAttachmentExtensions = ["jpeg", "jpg", "png", "gif", "webp"];
const audioAttachmentExtensions = ["wav", "mp3", "m4a"];
@ -21,15 +22,15 @@ export function createStarboardEmbedFromMessage(
name: `${msg.author.username}#${msg.author.discriminator}`,
},
fields: [],
timestamp: new Date(msg.timestamp).toISOString(),
timestamp: msg.createdAt,
};
if (color != null) {
embed.color = color;
}
if (msg.author.avatarURL) {
embed.author.icon_url = msg.author.avatarURL;
if (msg.author.avatarURL()) {
embed.author.icon_url = msg.author.avatarURL()!;
}
// The second condition here checks for messages with only an image link that is then embedded.
@ -59,15 +60,15 @@ export function createStarboardEmbedFromMessage(
}
// If there are no embeds, add the first image attachment explicitly
else if (msg.attachments.length) {
else if (msg.attachments.size) {
for (const attachment of msg.attachments) {
const ext = path
.extname(attachment.filename)
.extname(attachment[1].name!)
.slice(1)
.toLowerCase();
if (imageAttachmentExtensions.includes(ext)) {
embed.image = { url: attachment.url };
embed.image = { url: attachment[1].url };
break;
}