Bug fixes and ~~performance~~ typing improvements
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index c83512c..1470832 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -2,29 +2,20 @@
export async function callback(client, oldMessage, newMessage) {
if (newMessage.author.id === client.user.id) return;
- const {
- log,
- NucleusColors,
- entry,
- renderUser,
- renderDelta,
- renderNumberDelta,
- renderChannel
- } = newMessage.channel.client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } =
+ newMessage.channel.client.logger;
newMessage.reference = newMessage.reference || {};
let newContent = newMessage.cleanContent.replaceAll("`", "‘");
let oldContent = oldMessage.cleanContent.replaceAll("`", "‘");
let attachmentJump = "";
- const config = (await client.database.guilds.read(newMessage.guild.id))
- .logging.attachments.saved[newMessage.channel.id + newMessage.id];
+ const config = (await client.database.guilds.read(newMessage.guild.id)).logging.attachments.saved[
+ newMessage.channel.id + newMessage.id
+ ];
if (config) {
attachmentJump = ` [[View attachments]](${config})`;
}
if (newContent === oldContent) {
- if (
- !oldMessage.flags.has("CROSSPOSTED") &&
- newMessage.flags.has("CROSSPOSTED")
- ) {
+ if (!oldMessage.flags.has("CROSSPOSTED") && newMessage.flags.has("CROSSPOSTED")) {
const data = {
meta: {
type: "messageAnnounce",
@@ -39,14 +30,8 @@
},
list: {
messageId: entry(newMessage.id, `\`${newMessage.id}\``),
- sentBy: entry(
- newMessage.author.id,
- renderUser(newMessage.author)
- ),
- sentIn: entry(
- newMessage.channel.id,
- renderChannel(newMessage.channel)
- ),
+ sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
+ sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
sent: entry(
new Date(newMessage.createdTimestamp),
renderDelta(new Date(newMessage.createdTimestamp))
@@ -55,19 +40,10 @@
new Date(newMessage.editedTimestamp),
renderDelta(new Date(newMessage.editedTimestamp))
),
- mentions: renderNumberDelta(
- oldMessage.mentions.users.size,
- newMessage.mentions.users.size
- ),
+ mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
attachments: entry(
- renderNumberDelta(
- oldMessage.attachments.size,
- newMessage.attachments.size
- ),
- renderNumberDelta(
- oldMessage.attachments.size,
- newMessage.attachments.size
- ) + attachmentJump
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
)
},
hidden: {
@@ -80,10 +56,8 @@
if (!newMessage.editedTimestamp) {
return;
}
- if (newContent.length > 256)
- newContent = newContent.substring(0, 253) + "...";
- if (oldContent.length > 256)
- oldContent = oldContent.substring(0, 253) + "...";
+ if (newContent.length > 256) newContent = newContent.substring(0, 253) + "...";
+ if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + "...";
const data = {
meta: {
type: "messageUpdate",
@@ -98,39 +72,19 @@
(oldContent
? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n`
: "**Before:** *Message had no content*\n") +
- (newContent
- ? `**After:**\n\`\`\`\n${newContent}\n\`\`\``
- : "**After:** *Message had no content*"),
+ (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : "**After:** *Message had no content*"),
end: `[[Jump to message]](${newMessage.url})`
},
list: {
messageId: entry(newMessage.id, `\`${newMessage.id}\``),
sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
- sentIn: entry(
- newMessage.channel.id,
- renderChannel(newMessage.channel)
- ),
- sent: entry(
- new Date(newMessage.createdTimestamp),
- renderDelta(new Date(newMessage.createdTimestamp))
- ),
- edited: entry(
- new Date(newMessage.editedTimestamp),
- renderDelta(new Date(newMessage.editedTimestamp))
- ),
- mentions: renderNumberDelta(
- oldMessage.mentions.users.size,
- newMessage.mentions.users.size
- ),
+ sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
+ sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
+ edited: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
+ mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
attachments: entry(
- renderNumberDelta(
- oldMessage.attachments.size,
- newMessage.attachments.size
- ),
- renderNumberDelta(
- oldMessage.attachments.size,
- newMessage.attachments.size
- ) + attachmentJump
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
),
repliedTo: entry(
newMessage.reference.messageId || null,