Update CompleteTimestamps.plugin.js
This commit is contained in:
parent
852d59f6f9
commit
7a74a0cdc9
|
@ -2,7 +2,7 @@
|
||||||
* @name CompleteTimestamps
|
* @name CompleteTimestamps
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 1.5.2
|
* @version 1.5.3
|
||||||
* @description Replaces Timestamps with your own custom Timestamps
|
* @description Replaces Timestamps with your own custom Timestamps
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -17,12 +17,15 @@ module.exports = (_ => {
|
||||||
"info": {
|
"info": {
|
||||||
"name": "CompleteTimestamps",
|
"name": "CompleteTimestamps",
|
||||||
"author": "DevilBro",
|
"author": "DevilBro",
|
||||||
"version": "1.5.2",
|
"version": "1.5.3",
|
||||||
"description": "Replaces Timestamps with your own custom Timestamps"
|
"description": "Replaces Timestamps with your own custom Timestamps"
|
||||||
},
|
},
|
||||||
"changeLog": {
|
"changeLog": {
|
||||||
|
"added": {
|
||||||
|
"Audit Logs": "Logs are now also affected by the plugin"
|
||||||
|
},
|
||||||
"fixed": {
|
"fixed": {
|
||||||
"Mini Stamp Tooltip": "Fixes the issue where tooltips for mini time stamps wouldn't show, smh this is discord's own fault for their shitty css"
|
"Embeds": "Fixed Issue where timestamps of some embeds weren't affected"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -72,15 +75,16 @@ module.exports = (_ => {
|
||||||
onLoad () {
|
onLoad () {
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
settings: {
|
settings: {
|
||||||
showInChat: {value: true, description: "Replace chat timestamp with complete timestamp"},
|
showInChat: {value: true, description: "Replace Chat Timestamps with complete Timestamps"},
|
||||||
showInEmbed: {value: true, description: "Replace embed timestamp with complete timestamp"},
|
showInEmbed: {value: true, description: "Replace Embed Timestamps with complete Timestamps"},
|
||||||
changeForChat: {value: true, description: "Change the time for the chat time tooltips"},
|
showInAuditLogs: {value: true, description: "Replace Audit Log Timestamps with complete Timestamps"},
|
||||||
changeForEdit: {value: true, description: "Change the time for the edited time tooltips"},
|
changeForChat: {value: true, description: "Change the Time for Chat Time Tooltips"},
|
||||||
displayTime: {value: true, description: "Display the time in the timestamp"},
|
changeForEdit: {value: true, description: "Change the Time for Edited Time Tooltips"},
|
||||||
displayDate: {value: true, description: "Display the date in the timestamp"},
|
displayTime: {value: true, description: "Display the Time in Timestamps"},
|
||||||
cutSeconds: {value: false, description: "Cut off seconds of the time"},
|
displayDate: {value: true, description: "Display the Date in Timestamps"},
|
||||||
forceZeros: {value: false, description: "Force leading zeros"},
|
cutSeconds: {value: false, description: "Cut off Seconds of the Time"},
|
||||||
otherOrder: {value: false, description: "Show the time before the date"}
|
forceZeros: {value: false, description: "Force leading Zeros"},
|
||||||
|
otherOrder: {value: false, description: "Show the Time before the Date"}
|
||||||
},
|
},
|
||||||
choices: {
|
choices: {
|
||||||
timestampLang: {value: "$discord", description: "Chat Timestamp Format"},
|
timestampLang: {value: "$discord", description: "Chat Timestamp Format"},
|
||||||
|
@ -101,7 +105,8 @@ module.exports = (_ => {
|
||||||
MessageHeader: "default",
|
MessageHeader: "default",
|
||||||
MessageContent: "type",
|
MessageContent: "type",
|
||||||
Embed: "render",
|
Embed: "render",
|
||||||
SystemMessage: "default"
|
SystemMessage: "default",
|
||||||
|
AuditLog: "render"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -297,10 +302,13 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
processEmbed (e) {
|
processEmbed (e) {
|
||||||
if (e.instance.props.embed.timestamp && settings.showInEmbed) {
|
if (e.instance.props.embed && e.instance.props.embed.timestamp && settings.showInEmbed) {
|
||||||
let process = returnvalue => {
|
let process = returnvalue => {
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(returnvalue, {props: [["className", BDFDB.disCN.embedfootertext]]});
|
let [children, index] = BDFDB.ReactUtils.findParent(returnvalue, {props: [["className", BDFDB.disCN.embedfootertext]]});
|
||||||
if (index > -1 && BDFDB.ArrayUtils.is(children[index].props.children)) children[index].props.children.splice(children[index].props.children.length - 1, 1, this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.embed.timestamp._i));
|
if (index > -1) {
|
||||||
|
if (BDFDB.ArrayUtils.is(children[index].props.children)) children[index].props.children[children[index].props.children.length - 1] = this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.embed.timestamp._i);
|
||||||
|
else children[index].props.children = this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.embed.timestamp._i);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (typeof e.returnvalue.props.children == "function") {
|
if (typeof e.returnvalue.props.children == "function") {
|
||||||
let childrenRender = e.returnvalue.props.children;
|
let childrenRender = e.returnvalue.props.children;
|
||||||
|
@ -315,11 +323,31 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
processSystemMessage (e) {
|
processSystemMessage (e) {
|
||||||
if (settings.showInChat) {
|
if (e.instance.props.timestamp && settings.showInChat) {
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "time"});
|
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "time"});
|
||||||
if (index > -1) children[index].props.children = this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.timestamp._i);
|
if (index > -1) children[index].props.children = this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.timestamp._i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processAuditLog (e) {
|
||||||
|
if (e.instance.props.log && settings.showInAuditLogs) {
|
||||||
|
if (typeof e.returnvalue.props.children == "function") {
|
||||||
|
let childrenRender = e.returnvalue.props.children;
|
||||||
|
e.returnvalue.props.children = (...args) => {
|
||||||
|
let children = childrenRender(...args);
|
||||||
|
this.editLog(e.instance.props.log, children);
|
||||||
|
return children;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else this.editLog(e.instance.props.log, e.returnvalue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editLog (log, returnvalue) {
|
||||||
|
if (!log || !returnvalue) return;
|
||||||
|
let [children, index] = BDFDB.ReactUtils.findParent(returnvalue, {props: [["className", "timestamp-1mruiI"]]});
|
||||||
|
if (index > -1) children[index].props.children = this.getTimestamp(languages[choices.timestampLang].id, log.timestampStart._i);
|
||||||
|
}
|
||||||
|
|
||||||
changeTimestamp (parent, index, change = {}) {
|
changeTimestamp (parent, index, change = {}) {
|
||||||
let type = parent[index].type && parent[index].type.type || parent[index].type;
|
let type = parent[index].type && parent[index].type.type || parent[index].type;
|
||||||
|
@ -354,7 +382,7 @@ module.exports = (_ => {
|
||||||
let timeObj = time || new Date();
|
let timeObj = time || new Date();
|
||||||
if (typeof time == "string" || typeof time == "number") timeObj = new Date(time);
|
if (typeof time == "string" || typeof time == "number") timeObj = new Date(time);
|
||||||
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
|
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
|
||||||
if (timeObj.toString() == "Invalid Date") return;
|
if (timeObj.toString() == "Invalid Date" || timeObj.constructor != Date) return;
|
||||||
let timeString = "";
|
let timeString = "";
|
||||||
if (languageId != "own") {
|
if (languageId != "own") {
|
||||||
let timestamp = [];
|
let timestamp = [];
|
||||||
|
|
Loading…
Reference in New Issue