Revert "stuff"

This reverts commit 1ffef13f92.
This commit is contained in:
Mirco Wittrien 2021-03-10 10:58:18 +01:00
parent 1ffef13f92
commit b48abd5f2e
6 changed files with 103 additions and 150 deletions

View File

@ -2,7 +2,7 @@
* @name BDFDB
* @author DevilBro
* @authorId 278543574059057154
* @version 1.4.5
* @version 1.4.4
* @description Required Library for DevilBro's Plugins
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -22,10 +22,15 @@ module.exports = (_ => {
"info": {
"name": "BDFDB",
"author": "DevilBro",
"version": "1.4.5",
"version": "1.4.4",
"description": "Required Library for DevilBro's Plugins"
},
"rawUrl": `https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js`
"rawUrl": `https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js`,
"changeLog": {
"progress": {
"Crash Issue": "If you encounter a crash while using the chat textarea to write a message, then you'll need to reinstall BD, this has nothing to do with any plugins"
}
}
};
const DiscordObjects = {};
@ -5433,9 +5438,9 @@ module.exports = (_ => {
disabled: props.isDisabled,
onClick: _ => {
if (!props.isSelected) {
let color = props.isCustom && props.color == null ? (props.swatches.props.color || "rgba(0, 0, 0, 1)") : props.color;
let color = props.isCustom && props.color == null ? (props.swatches.props.selectedColor || "rgba(0, 0, 0, 1)") : props.color;
if (typeof props.swatches.props.onColorChange == "function") props.swatches.props.onColorChange(BDFDB.ColorUtils.convert(color, "RGBCOMP"));
props.swatches.props.color = color;
props.swatches.props.selectedColor = color;
props.swatches.props.customColor = props.isCustom ? color : props.swatches.props.customColor;
props.swatches.props.customSelected = props.isCustom;
BDFDB.ReactUtils.forceUpdate(props.swatches);
@ -5475,13 +5480,13 @@ module.exports = (_ => {
align: InternalComponents.LibraryComponents.PopoutContainer.Align.CENTER,
renderPopout: _ => {
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.ColorPicker, Object.assign({}, props.pickerConfig, {
color: props.swatches.props.color,
color: props.swatches.props.selectedColor,
onColorChange: color => {
let comp = BDFDB.ColorUtils.convert(color, "RGBCOMP");
if (typeof props.swatches.props.onColorChange == "function") props.swatches.props.onColorChange(comp);
if (props.pickerConfig && typeof props.pickerConfig.onColorChange == "function") props.pickerConfig.onColorChange(comp);
props.color = color;
props.swatches.props.color = color;
props.swatches.props.selectedColor = color;
props.swatches.props.customColor = color;
props.swatches.props.customSelected = true;
BDFDB.ReactUtils.forceUpdate(props.swatches);
@ -5504,17 +5509,17 @@ module.exports = (_ => {
swatches: this,
color: color,
isCustom: false,
isSelected: !this.props.customSelected && color == this.props.color,
isSelected: !this.props.customSelected && color === this.props.selectedColor,
isDisabled: this.props.disabled
})
})
});
}
render() {
this.props.color = BDFDB.ObjectUtils.is(this.props.color) ? this.props.color : BDFDB.ColorUtils.convert(this.props.color, "RGBA");
this.props.selectedColor = this.props.selectedColor || (BDFDB.ObjectUtils.is(this.props.color) ? this.props.color : BDFDB.ColorUtils.convert(this.props.color, "RGBA"));
this.props.colors = (BDFDB.ArrayUtils.is(this.props.colors) ? this.props.colors : [null, 5433630, 3066993, 1752220, 3447003, 3429595, 8789737, 10181046, 15277667, 15286558, 15158332, 15105570, 15844367, 13094093, 7372936, 6513507, 16777215, 3910932, 2067276, 1146986, 2123412, 2111892, 7148717, 7419530, 11342935, 11345940, 10038562, 11027200, 12745742, 9936031, 6121581, 2894892]).map(c => BDFDB.ColorUtils.convert(c, "RGBA"));
this.props.colorRows = this.props.colors.length ? [this.props.colors.slice(0, parseInt(this.props.colors.length/2)), this.props.colors.slice(parseInt(this.props.colors.length/2))] : [];
this.props.customColor = !this.props.color || !this.props.customSelected && this.props.colors.indexOf(this.props.color) > -1 ? null : this.props.color;
this.props.customColor = !this.props.selectedColor || !this.props.customSelected && this.props.colors.indexOf(this.props.selectedColor) > -1 ? null : this.props.selectedColor;
this.props.customSelected = !!this.props.customColor;
this.props.pickerConfig = BDFDB.ObjectUtils.is(this.props.pickerConfig) ? this.props.pickerConfig : {gradient: true, alpha: true};

View File

@ -386,47 +386,37 @@ module.exports = (_ => {
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let hours = timeObj.getHours();
let minutes = timeObj.getMinutes();
let seconds = timeObj.getSeconds();
let milliSeconds = timeObj.getMilliseconds();
let day = timeObj.getDate();
let month = timeObj.getMonth()+1;
let timeMode = "";
let now = new Date();
let daysAgo = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats[isTooltip ? "ownFormatTool" : "ownFormat"].indexOf("$timemode") > -1) {
timeMode = hours >= 12 ? "PM" : "AM";
hours = hours % 12;
hours = hours ? hours : 12;
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(formats[isTooltip ? "ownFormatTool" : "ownFormat"]
.replace(/\$hour/g, settings.forceZeros && hours < 10 ? "0" + hours : hours)
.replace(/\$minute/g, minutes < 10 ? "0" + minutes : minutes)
.replace(/\$second/g, seconds < 10 ? "0" + seconds : seconds)
.replace(/\$msecond/g, settings.forceZeros ? (milliSeconds < 10 ? "00" + milliSeconds : (milliSeconds < 100 ? "0" + milliSeconds : milliSeconds)) : milliSeconds)
.replace(/\$timemode/g, timeMode)
timeString = formats[isTooltip ? "ownFormatTool" : "ownFormat"]
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysAgo ? (daysAgo > 1 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysAgo) : BDFDB.LanguageUtils.LanguageStrings[`SEARCH_SHORTCUT_${daysAgo == 1 ? "YESTERDAY" : "TODAY"}`]) : "")
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" "));
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}

View File

@ -289,51 +289,41 @@ module.exports = (_ => {
let timeObj = time || new Date();
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" || typeof timeObj.toLocaleDateString != "function") return;
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let hours = timeObj.getHours();
let minutes = timeObj.getMinutes();
let seconds = timeObj.getSeconds();
let milliSeconds = timeObj.getMilliseconds();
let day = timeObj.getDate();
let month = timeObj.getMonth()+1;
let timeMode = "";
let now = new Date();
let daysAgo = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timeMode = hours >= 12 ? "PM" : "AM";
hours = hours % 12;
hours = hours ? hours : 12;
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hours < 10 ? "0" + hours : hours)
.replace(/\$minute/g, minutes < 10 ? "0" + minutes : minutes)
.replace(/\$second/g, seconds < 10 ? "0" + seconds : seconds)
.replace(/\$msecond/g, settings.forceZeros ? (milliSeconds < 10 ? "00" + milliSeconds : (milliSeconds < 100 ? "0" + milliSeconds : milliSeconds)) : milliSeconds)
.replace(/\$timemode/g, timeMode)
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysAgo ? (daysAgo > 1 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysAgo) : BDFDB.LanguageUtils.LanguageStrings[`SEARCH_SHORTCUT_${daysAgo == 1 ? "YESTERDAY" : "TODAY"}`]) : "")
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" "));
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}

View File

@ -305,51 +305,41 @@ module.exports = (_ => {
let timeObj = time || new Date();
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" || typeof timeObj.toLocaleDateString != "function") return;
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let hours = timeObj.getHours();
let minutes = timeObj.getMinutes();
let seconds = timeObj.getSeconds();
let milliSeconds = timeObj.getMilliseconds();
let day = timeObj.getDate();
let month = timeObj.getMonth()+1;
let timeMode = "";
let now = new Date();
let daysAgo = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timeMode = hours >= 12 ? "PM" : "AM";
hours = hours % 12;
hours = hours ? hours : 12;
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hours < 10 ? "0" + hours : hours)
.replace(/\$minute/g, minutes < 10 ? "0" + minutes : minutes)
.replace(/\$second/g, seconds < 10 ? "0" + seconds : seconds)
.replace(/\$msecond/g, settings.forceZeros ? (milliSeconds < 10 ? "00" + milliSeconds : (milliSeconds < 100 ? "0" + milliSeconds : milliSeconds)) : milliSeconds)
.replace(/\$timemode/g, timeMode)
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysAgo ? (daysAgo > 1 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysAgo) : BDFDB.LanguageUtils.LanguageStrings[`SEARCH_SHORTCUT_${daysAgo == 1 ? "YESTERDAY" : "TODAY"}`]) : "")
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" "));
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}

View File

@ -327,56 +327,46 @@ module.exports = (_ => {
}));
}
}
getTimestamp (languageId, time) {
let timeObj = time || new Date();
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" || typeof timeObj.toLocaleDateString != "function") return;
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let hours = timeObj.getHours();
let minutes = timeObj.getMinutes();
let seconds = timeObj.getSeconds();
let milliSeconds = timeObj.getMilliseconds();
let day = timeObj.getDate();
let month = timeObj.getMonth()+1;
let timeMode = "";
let now = new Date();
let daysAgo = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timeMode = hours >= 12 ? "PM" : "AM";
hours = hours % 12;
hours = hours ? hours : 12;
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hours < 10 ? "0" + hours : hours)
.replace(/\$minute/g, minutes < 10 ? "0" + minutes : minutes)
.replace(/\$second/g, seconds < 10 ? "0" + seconds : seconds)
.replace(/\$msecond/g, settings.forceZeros ? (milliSeconds < 10 ? "00" + milliSeconds : (milliSeconds < 100 ? "0" + milliSeconds : milliSeconds)) : milliSeconds)
.replace(/\$timemode/g, timeMode)
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysAgo ? (daysAgo > 1 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysAgo) : BDFDB.LanguageUtils.LanguageStrings[`SEARCH_SHORTCUT_${daysAgo == 1 ? "YESTERDAY" : "TODAY"}`]) : "")
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" "));
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}

View File

@ -166,20 +166,18 @@ module.exports = (_ => {
this.defaults = {
settings: {
displayTime: {value: false, cat: "settings", description: "Display the Time in the Timestamp"},
displayDate: {value: true, cat: "settings", description: "Display the Date in the Timestamp"},
cutSeconds: {value: false, cat: "settings", description: "Cut off seconds of the time"},
forceZeros: {value: false, cat: "settings", description: "Force leading zeros"},
otherOrder: {value: false, cat: "settings", description: "Show the time before the date"},
addIcon: {value: true, cat: "tooltip", description: "GUILD_CREATE_UPLOAD_ICON_LABEL"},
addOwner: {value: true, cat: "tooltip", description: "GUILD_OWNER"},
addCreation: {value: true, cat: "tooltip", description: "creation_date"},
addJoin: {value: true, cat: "tooltip", description: "join_date"},
addMembers: {value: true, cat: "tooltip", description: "MEMBERS"},
addChannels: {value: true, cat: "tooltip", description: "CHANNELS"},
addRoles: {value: true, cat: "tooltip", description: "ROLES"},
addBoosters: {value: true, cat: "tooltip", description: "SUBSCRIPTIONS_TITLE"},
addRegion: {value: true, cat: "tooltip", description: "REGION"}
addIcon: {value: true, cat: "tooltip", description: "GUILD_CREATE_UPLOAD_ICON_LABEL"},
addOwner: {value: true, cat: "tooltip", description: "GUILD_OWNER"},
addCreation: {value: true, cat: "tooltip", description: "creation_date"},
addJoin: {value: true, cat: "tooltip", description: "join_date"},
addMembers: {value: true, cat: "tooltip", description: "MEMBERS"},
addChannels: {value: true, cat: "tooltip", description: "CHANNELS"},
addRoles: {value: true, cat: "tooltip", description: "ROLES"},
addBoosters: {value: true, cat: "tooltip", description: "SUBSCRIPTIONS_TITLE"},
addRegion: {value: true, cat: "tooltip", description: "REGION"}
},
colors: {
tooltipColor: {value: "", description: "Tooltip Color"}
@ -477,51 +475,41 @@ module.exports = (_ => {
let timeObj = time || new Date();
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" || typeof timeObj.toLocaleDateString != "function") return;
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
timestamp.push(timeObj.toLocaleDateString(languageId));
timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let hours = timeObj.getHours();
let minutes = timeObj.getMinutes();
let seconds = timeObj.getSeconds();
let milliSeconds = timeObj.getMilliseconds();
let day = timeObj.getDate();
let month = timeObj.getMonth()+1;
let timeMode = "";
let now = new Date();
let daysAgo = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timeMode = hours >= 12 ? "PM" : "AM";
hours = hours % 12;
hours = hours ? hours : 12;
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hours < 10 ? "0" + hours : hours)
.replace(/\$minute/g, minutes < 10 ? "0" + minutes : minutes)
.replace(/\$second/g, seconds < 10 ? "0" + seconds : seconds)
.replace(/\$msecond/g, settings.forceZeros ? (milliSeconds < 10 ? "00" + milliSeconds : (milliSeconds < 100 ? "0" + milliSeconds : milliSeconds)) : milliSeconds)
.replace(/\$timemode/g, timeMode)
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysAgo ? (daysAgo > 1 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysAgo) : BDFDB.LanguageUtils.LanguageStrings[`SEARCH_SHORTCUT_${daysAgo == 1 ? "YESTERDAY" : "TODAY"}`]) : "")
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" "));
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}