mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Ignore embed thumbnail/image width/height updates in edit logs
This commit is contained in:
parent
5b6941a1f6
commit
32782d0bfa
3 changed files with 29 additions and 5 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -5652,6 +5652,11 @@
|
||||||
"resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz",
|
||||||
"integrity": "sha1-ZuXOH3btJ7QwPYxlEujRIW6BBrw="
|
"integrity": "sha1-ZuXOH3btJ7QwPYxlEujRIW6BBrw="
|
||||||
},
|
},
|
||||||
|
"lodash.clonedeep": {
|
||||||
|
"version": "4.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
|
||||||
|
"integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8="
|
||||||
|
},
|
||||||
"lodash.debounce": {
|
"lodash.debounce": {
|
||||||
"version": "4.0.8",
|
"version": "4.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"last-commit-log": "^2.1.0",
|
"last-commit-log": "^2.1.0",
|
||||||
"lodash.at": "^4.6.0",
|
"lodash.at": "^4.6.0",
|
||||||
"lodash.chunk": "^4.2.0",
|
"lodash.chunk": "^4.2.0",
|
||||||
|
"lodash.clonedeep": "^4.5.0",
|
||||||
"lodash.difference": "^4.5.0",
|
"lodash.difference": "^4.5.0",
|
||||||
"lodash.has": "^4.5.2",
|
"lodash.has": "^4.5.2",
|
||||||
"lodash.intersection": "^4.4.0",
|
"lodash.intersection": "^4.4.0",
|
||||||
|
|
|
@ -25,6 +25,7 @@ import { GuildArchives } from "../data/GuildArchives";
|
||||||
import { GuildCases } from "../data/GuildCases";
|
import { GuildCases } from "../data/GuildCases";
|
||||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||||
import { renderTemplate, TemplateParseError } from "../templateFormatter";
|
import { renderTemplate, TemplateParseError } from "../templateFormatter";
|
||||||
|
import cloneDeep from "lodash.clonedeep";
|
||||||
|
|
||||||
interface ILogChannel {
|
interface ILogChannel {
|
||||||
include?: string[];
|
include?: string[];
|
||||||
|
@ -433,14 +434,31 @@ export class LogsPlugin extends ZeppelinPlugin<ILogsPluginConfig> {
|
||||||
async onMessageUpdate(savedMessage: SavedMessage, oldSavedMessage: SavedMessage) {
|
async onMessageUpdate(savedMessage: SavedMessage, oldSavedMessage: SavedMessage) {
|
||||||
// To log a message update, either the message content or a rich embed has to change
|
// To log a message update, either the message content or a rich embed has to change
|
||||||
let logUpdate = false;
|
let logUpdate = false;
|
||||||
const oldRichEmbed = (oldSavedMessage.data.embeds || []).find(e => (e as Embed).type === "rich");
|
|
||||||
const newRichEmbed = (savedMessage.data.embeds || []).find(e => (e as Embed).type === "rich");
|
const oldEmbedsToCompare = ((oldSavedMessage.data.embeds || []) as Embed[])
|
||||||
|
.map(e => cloneDeep(e))
|
||||||
|
.filter(e => (e as Embed).type === "rich");
|
||||||
|
|
||||||
|
const newEmbedsToCompare = ((savedMessage.data.embeds || []) as Embed[])
|
||||||
|
.map(e => cloneDeep(e))
|
||||||
|
.filter(e => (e as Embed).type === "rich");
|
||||||
|
|
||||||
|
for (const embed of [...oldEmbedsToCompare, ...newEmbedsToCompare]) {
|
||||||
|
if (embed.thumbnail) {
|
||||||
|
delete embed.thumbnail.width;
|
||||||
|
delete embed.thumbnail.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (embed.image) {
|
||||||
|
delete embed.image.width;
|
||||||
|
delete embed.image.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
oldSavedMessage.data.content !== savedMessage.data.content ||
|
oldSavedMessage.data.content !== savedMessage.data.content ||
|
||||||
((oldRichEmbed && !newRichEmbed) ||
|
oldEmbedsToCompare.length !== newEmbedsToCompare.length ||
|
||||||
(!oldRichEmbed && newRichEmbed) ||
|
JSON.stringify(oldEmbedsToCompare) !== JSON.stringify(newEmbedsToCompare)
|
||||||
JSON.stringify(oldRichEmbed) !== JSON.stringify(newRichEmbed))
|
|
||||||
) {
|
) {
|
||||||
logUpdate = true;
|
logUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue