Finish preliminary rework, ready to test
This commit is contained in:
parent
57893e7f76
commit
d0a1beb809
177 changed files with 854 additions and 707 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Message, EmbedField } from "discord.js";
|
||||
import { EMPTY_CHAR, messageLink } from "../../../utils";
|
||||
import { TStarboardOpts } from "../types";
|
||||
|
||||
|
@ -22,5 +23,6 @@ export function createStarboardPseudoFooterForMessage(
|
|||
return {
|
||||
name: EMPTY_CHAR,
|
||||
value: content,
|
||||
inline: false,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import { EmbedWith, EMPTY_CHAR, messageLink } from "../../../utils";
|
|||
import path from "path";
|
||||
import { createStarboardEmbedFromMessage } from "./createStarboardEmbedFromMessage";
|
||||
import { createStarboardPseudoFooterForMessage } from "./createStarboardPseudoFooterForMessage";
|
||||
import { Message, TextChannel } from "discord.js";
|
||||
|
||||
export async function saveMessageToStarboard(
|
||||
pluginData: GuildPluginData<StarboardPluginType>,
|
||||
|
@ -19,6 +20,6 @@ export async function saveMessageToStarboard(
|
|||
const embed = createStarboardEmbedFromMessage(msg, Boolean(starboard.copy_full_embed), starboard.color);
|
||||
embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, msg, starboard.star_emoji![0], starCount));
|
||||
|
||||
const starboardMessage = await (channel as TextChannel).createMessage({ embed });
|
||||
const starboardMessage = await (channel as TextChannel).send(embed);
|
||||
await pluginData.state.starboardMessages.createStarboardMessage(channel.id, msg.id, starboardMessage.id);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { noop } from "../../../utils";
|
|||
import { createStarboardPseudoFooterForMessage } from "./createStarboardPseudoFooterForMessage";
|
||||
import { TStarboardOpts } from "../types";
|
||||
import Timeout = NodeJS.Timeout;
|
||||
import { Message } from "discord.js";
|
||||
|
||||
const DEBOUNCE_DELAY = 1000;
|
||||
const debouncedUpdates: Record<string, Timeout> = {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue