stuff
This commit is contained in:
parent
64a9f5bee1
commit
cccd0ac3c7
|
@ -672,10 +672,10 @@ img:not([src]), img[src=""], img[src="null"] {
|
|||
[REPLACE_CLASS_dateinputpreviewsuffix] {
|
||||
font-weight: 600;
|
||||
}
|
||||
[REPLACE_CLASS_dateinputpreviewprefix] {
|
||||
[REPLACE_CLASS_dateinputpreviewprefix]:not(:empty) {
|
||||
margin-right: 6px;
|
||||
}
|
||||
[REPLACE_CLASS_dateinputpreviewsuffix] {
|
||||
[REPLACE_CLASS_dateinputpreviewsuffix]:not(:empty) {
|
||||
margin-left: 6px;
|
||||
}
|
||||
[REPLACE_CLASS_dateinputfield] {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name CreationDate
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 1.4.0
|
||||
* @version 1.4.1
|
||||
* @description Displays the Creation Date of an Account in the UserPopout and UserModal
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -17,12 +17,12 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "CreationDate",
|
||||
"author": "DevilBro",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"description": "Displays the Creation Date of an Account in the UserPopout and UserModal"
|
||||
},
|
||||
"changeLog": {
|
||||
"fixed": {
|
||||
"Settings": "Work again"
|
||||
"improved": {
|
||||
"New Settings": "Changed the Settings Panel for the Plugin, Settings got reset sowwy ~w~"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -65,31 +65,18 @@ module.exports = (_ => {
|
|||
return template.content.firstElementChild;
|
||||
}
|
||||
} : (([Plugin, BDFDB]) => {
|
||||
var languages;
|
||||
var settings = {}, choices = {}, formats = {}, amounts = {};
|
||||
|
||||
return class CreationDate extends Plugin {
|
||||
onLoad () {
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addInUserPopout: {value: true, description: "Add in User Popouts"},
|
||||
addInUserProfil: {value: true, description: "Add in User Profile Modal"},
|
||||
displayText: {value: true, description: "Display 'Created on' Text in the Timestamp"},
|
||||
displayTime: {value: true, description: "Display the Time in the Timestamp"},
|
||||
displayDate: {value: true, description: "Display the Date in the Timestamp"},
|
||||
cutSeconds: {value: false, description: "Cut off Seconds of the Time"},
|
||||
forceZeros: {value: false, description: "Force leading Zeros"},
|
||||
otherOrder: {value: false, description: "Show the Time before the Date"},
|
||||
useDateInDaysAgo: {value: false, description: "Use the Date instead of 'x days ago' in $daysago Placeholder"}
|
||||
general: {
|
||||
displayText: {value: true, description: "Display '{{presuffix}}' in the Date"}
|
||||
},
|
||||
choices: {
|
||||
creationDateLang: {value: "$discord", description: "Creation Date Format"}
|
||||
places: {
|
||||
userPopout: {value: true, description: "User Popouts"},
|
||||
userProfile: {value: true, description: "User Profile Modal"}
|
||||
},
|
||||
formats: {
|
||||
ownFormat: {value: "$hour:$minute:$second, $day.$month.$year", description: "Own Format"}
|
||||
},
|
||||
amounts: {
|
||||
maxDaysAgo: {value: 0, min: 0, description: "Maximum Count of Days displayed in the $daysago Placeholder", note: "0 equals no Limit"}
|
||||
dates: {
|
||||
creationDate: {value: {}, description: "Creation Date"},
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -103,171 +90,79 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
languages = BDFDB.ObjectUtils.deepAssign({
|
||||
own: {
|
||||
"name": "Own",
|
||||
id: "own"
|
||||
}
|
||||
}, BDFDB.LanguageUtils.languages);
|
||||
|
||||
this.forceUpdateAll();
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
onStop () {
|
||||
this.forceUpdateAll();
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
getSettingsPanel (collapseStates = {}) {
|
||||
let settingsPanel, settingsItems = [];
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Settings",
|
||||
let settingsPanel;
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
|
||||
collapseStates: collapseStates,
|
||||
children: Object.keys(settings).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["settings", key],
|
||||
label: this.defaults.settings[key].description,
|
||||
value: settings[key],
|
||||
onChange: (value, instance) => {
|
||||
settings[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
||||
}
|
||||
}))
|
||||
}));
|
||||
children: _ => {
|
||||
let settingsItems = [];
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Format",
|
||||
collapseStates: collapseStates,
|
||||
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Select",
|
||||
plugin: this,
|
||||
keys: ["choices", key],
|
||||
label: this.defaults.choices[key].description,
|
||||
basis: "70%",
|
||||
value: choices[key],
|
||||
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value: id, label: lang.name}})),
|
||||
searchable: true,
|
||||
optionRenderer: lang => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
basis: "40%",
|
||||
children: lang.label
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
basis: "60%",
|
||||
children: this.getTimestamp(languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
},
|
||||
valueRenderer: lang => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
children: lang.label
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 1,
|
||||
shrink: 0,
|
||||
basis: "70%",
|
||||
children: this.getTimestamp(languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(formats).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["formats", key],
|
||||
label: this.defaults.formats[key].description,
|
||||
basis: "70%",
|
||||
value: formats[key],
|
||||
onChange: (value, instance) => {
|
||||
formats[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
||||
}
|
||||
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(amounts).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
childProps: {
|
||||
type: "number"
|
||||
},
|
||||
plugin: this,
|
||||
keys: ["amounts", key],
|
||||
label: this.defaults.amounts[key].description,
|
||||
note: this.defaults.amounts[key].note,
|
||||
basis: "20%",
|
||||
min: this.defaults.amounts[key].min,
|
||||
max: this.defaults.amounts[key].max,
|
||||
value: amounts[key]
|
||||
})))
|
||||
}));
|
||||
settingsItems.push(Object.keys(this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["general", key],
|
||||
label: key == "displayText" ? this.defaults.general[key].description.replace("{{presuffix}}", this.labels.created_at.replace("{{time}}", "").trim()) : this.defaults.general[key].description,
|
||||
value: this.settings.general[key]
|
||||
})));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Placeholder Guide",
|
||||
collapseStates: collapseStates,
|
||||
children: [
|
||||
"$hour will be replaced with the hour of the date",
|
||||
"$minute will be replaced with the minutes of the date",
|
||||
"$second will be replaced with the seconds of the date",
|
||||
"$msecond will be replaced with the milliseconds of the date",
|
||||
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
||||
"$year will be replaced with the year of the date",
|
||||
"$yearS will be replaced with the year in short form",
|
||||
"$month will be replaced with the month of the date",
|
||||
"$day will be replaced with the day of the date",
|
||||
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
||||
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
||||
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
||||
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
|
||||
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
|
||||
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
|
||||
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
|
||||
children: string
|
||||
}))
|
||||
}));
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
}));
|
||||
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
||||
title: "Add Date in:",
|
||||
children: Object.keys(this.defaults.places).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["places", key],
|
||||
label: this.defaults.places[key].description,
|
||||
value: this.settings.places[key]
|
||||
}))
|
||||
}));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
}));
|
||||
|
||||
settingsItems.push(Object.keys(this.defaults.dates).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.DateInput, Object.assign({}, this.settings.dates[key], {
|
||||
label: this.defaults.dates[key].description,
|
||||
prefix: _ => (this.settings.general.displayText && this.labels.created_at.split("{{time}}")[0] || "").trim(),
|
||||
suffix: _ => (this.settings.general.displayText && this.labels.created_at.split("{{time}}")[1] || "").trim(),
|
||||
onChange: valueObj => {
|
||||
this.SettingsUpdated = true;
|
||||
this.settings.dates[key] = valueObj;
|
||||
BDFDB.DataUtils.save(this.settings.dates, this, "dates");
|
||||
}
|
||||
}))));
|
||||
|
||||
return settingsItems.flat(10);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
this.forceUpdateAll();
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
forceUpdateAll () {
|
||||
settings = BDFDB.DataUtils.get(this, "settings");
|
||||
choices = BDFDB.DataUtils.get(this, "choices");
|
||||
formats = BDFDB.DataUtils.get(this, "formats");
|
||||
amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
processUserPopout (e) {
|
||||
if (e.instance.props.user && settings.addInUserPopout) {
|
||||
if (e.instance.props.user && this.settings.places.userPopout) {
|
||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
|
||||
if (index > -1) this.injectDate(children, 2, e.instance.props.user);
|
||||
}
|
||||
}
|
||||
|
||||
processAnalyticsContext (e) {
|
||||
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && settings.addInUserProfil) {
|
||||
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && this.settings.places.userProfile) {
|
||||
let renderChildren = e.returnvalue.props.children;
|
||||
e.returnvalue.props.children = (...args) => {
|
||||
let renderedChildren = renderChildren(...args);
|
||||
|
@ -279,33 +174,13 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
injectDate (children, index, user) {
|
||||
let timestamp = this.getTimestamp(languages[choices.creationDateLang].id, user.createdAt);
|
||||
let timestamp = BDFDB.LibraryComponents.DateInput.format(this.settings.dates.creationDate, user.createdAt);
|
||||
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||
className: BDFDB.disCNS._creationdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
|
||||
children: settings.displayText ? this.labels.created_at.replace("{{time}}", timestamp) : timestamp
|
||||
children: this.settings.general.displayText ? this.labels.created_at.replace("{{time}}", timestamp) : timestamp
|
||||
}));
|
||||
}
|
||||
|
||||
getTimestamp (languageId, time) {
|
||||
return BDFDB.StringUtils.formatTime(time, Object.assign({
|
||||
language: languageId,
|
||||
formatString: languageId == "own" && formats.ownFormat
|
||||
}, settings, amounts));
|
||||
}
|
||||
|
||||
cutOffSeconds (timeString) {
|
||||
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
||||
}
|
||||
|
||||
addLeadingZeros (timeString) {
|
||||
let charArray = timeString.split("");
|
||||
let numreg = /[0-9]/;
|
||||
for (let i = 0; i < charArray.length; i++) {
|
||||
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
||||
}
|
||||
return charArray.join("");
|
||||
}
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
||||
case "bg": // Bulgarian
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name JoinedAtDate
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 1.2.5
|
||||
* @version 1.2.6
|
||||
* @description Displays the Joined At Date of a Member in the UserPopout and UserModal
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -17,12 +17,12 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "JoinedAtDate",
|
||||
"author": "DevilBro",
|
||||
"version": "1.2.5",
|
||||
"version": "1.2.6",
|
||||
"description": "Displays the Joined At Date of a Member in the UserPopout and UserModal"
|
||||
},
|
||||
"changeLog": {
|
||||
"fixed": {
|
||||
"Settings": "Work again"
|
||||
"improved": {
|
||||
"New Settings": "Changed the Settings Panel for the Plugin, Settings got reset sowwy ~w~"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -65,8 +65,7 @@ module.exports = (_ => {
|
|||
return template.content.firstElementChild;
|
||||
}
|
||||
} : (([Plugin, BDFDB]) => {
|
||||
var loadedUsers, requestedUsers, languages;
|
||||
var settings = {}, choices = {}, formats = {}, amounts = {};
|
||||
var loadedUsers, requestedUsers;
|
||||
|
||||
return class JoinedAtDate extends Plugin {
|
||||
onLoad () {
|
||||
|
@ -74,25 +73,15 @@ module.exports = (_ => {
|
|||
requestedUsers = {};
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addInUserPopout: {value: true, description: "Add in User Popouts"},
|
||||
addInUserProfil: {value: true, description: "Add in User Profile Modal"},
|
||||
displayText: {value: true, description: "Display 'Joined on' text in the Timestamp"},
|
||||
displayTime: {value: true, description: "Display the Time in the Timestamp"},
|
||||
displayDate: {value: true, description: "Display the Date in the Timestamp"},
|
||||
cutSeconds: {value: false, description: "Cut off Seconds of the Time"},
|
||||
forceZeros: {value: false, description: "Force leading Zeros"},
|
||||
otherOrder: {value: false, description: "Show the Time before the Date"},
|
||||
useDateInDaysAgo: {value: false, description: "Use the Date instead of 'x days ago' in $daysago Placeholder"}
|
||||
general: {
|
||||
displayText: {value: true, description: "Display '{{presuffix}}' in the Date"}
|
||||
},
|
||||
choices: {
|
||||
joinedAtDateLang: {value: "$discord", description: "Joined At Date Format"}
|
||||
places: {
|
||||
userPopout: {value: true, description: "User Popouts"},
|
||||
userProfile: {value: true, description: "User Profile Modal"}
|
||||
},
|
||||
formats: {
|
||||
ownFormat: {value: "$hour:$minute:$second, $day.$month.$year", description: "Own Format"}
|
||||
},
|
||||
amounts: {
|
||||
maxDaysAgo: {value: 0, min: 0, description: "Maximum Count of Days displayed in the $daysago Placeholder", note: "0 equals no Limit"}
|
||||
dates: {
|
||||
joinedAtDate: {value: {}, description: "Joined at Date"},
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -105,171 +94,79 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
languages = BDFDB.ObjectUtils.deepAssign({
|
||||
own: {
|
||||
name: "Own",
|
||||
id: "own"
|
||||
}
|
||||
}, BDFDB.LanguageUtils.languages);
|
||||
|
||||
this.forceUpdateAll();
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
onStop () {
|
||||
this.forceUpdateAll();
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
getSettingsPanel (collapseStates = {}) {
|
||||
let settingsPanel, settingsItems = [];
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Settings",
|
||||
let settingsPanel;
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
|
||||
collapseStates: collapseStates,
|
||||
children: Object.keys(settings).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["settings", key],
|
||||
label: this.defaults.settings[key].description,
|
||||
value: settings[key],
|
||||
onChange: (value, instance) => {
|
||||
settings[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
||||
}
|
||||
}))
|
||||
}));
|
||||
children: _ => {
|
||||
let settingsItems = [];
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Format",
|
||||
collapseStates: collapseStates,
|
||||
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Select",
|
||||
plugin: this,
|
||||
keys: ["choices", key],
|
||||
label: this.defaults.choices[key].description,
|
||||
basis: "70%",
|
||||
value: choices[key],
|
||||
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value: id, label: lang.name}})),
|
||||
searchable: true,
|
||||
optionRenderer: lang => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
basis: "40%",
|
||||
children: lang.label
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
basis: "60%",
|
||||
children: this.getTimestamp(languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
},
|
||||
valueRenderer: lang => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
children: lang.label
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 1,
|
||||
shrink: 0,
|
||||
basis: "70%",
|
||||
children: this.getTimestamp(languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(formats).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["formats", key],
|
||||
label: this.defaults.formats[key].description,
|
||||
basis: "70%",
|
||||
value: formats[key],
|
||||
onChange: (value, instance) => {
|
||||
formats[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
||||
}
|
||||
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(amounts).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
childProps: {
|
||||
type: "number"
|
||||
},
|
||||
plugin: this,
|
||||
keys: ["amounts", key],
|
||||
label: this.defaults.amounts[key].description,
|
||||
note: this.defaults.amounts[key].note,
|
||||
basis: "20%",
|
||||
min: this.defaults.amounts[key].min,
|
||||
max: this.defaults.amounts[key].max,
|
||||
value: amounts[key]
|
||||
})))
|
||||
}));
|
||||
settingsItems.push(Object.keys(this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["general", key],
|
||||
label: key == "displayText" ? this.defaults.general[key].description.replace("{{presuffix}}", this.labels.joined_at.replace("{{time}}", "").trim()) : this.defaults.general[key].description,
|
||||
value: this.settings.general[key]
|
||||
})));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Placeholder Guide",
|
||||
collapseStates: collapseStates,
|
||||
children: [
|
||||
"$hour will be replaced with the hour of the date",
|
||||
"$minute will be replaced with the minutes of the date",
|
||||
"$second will be replaced with the seconds of the date",
|
||||
"$msecond will be replaced with the milliseconds of the date",
|
||||
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
||||
"$year will be replaced with the year of the date",
|
||||
"$yearS will be replaced with the year in short form",
|
||||
"$month will be replaced with the month of the date",
|
||||
"$day will be replaced with the day of the date",
|
||||
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
||||
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
||||
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
||||
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
|
||||
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
|
||||
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
|
||||
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
|
||||
children: string
|
||||
}))
|
||||
}));
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
}));
|
||||
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
||||
title: "Add Date in:",
|
||||
children: Object.keys(this.defaults.places).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["places", key],
|
||||
label: this.defaults.places[key].description,
|
||||
value: this.settings.places[key]
|
||||
}))
|
||||
}));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
}));
|
||||
|
||||
settingsItems.push(Object.keys(this.defaults.dates).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.DateInput, Object.assign({}, this.settings.dates[key], {
|
||||
label: this.defaults.dates[key].description,
|
||||
prefix: _ => (this.settings.general.displayText && this.labels.joined_at.split("{{time}}")[0] || "").trim(),
|
||||
suffix: _ => (this.settings.general.displayText && this.labels.joined_at.split("{{time}}")[1] || "").trim(),
|
||||
onChange: valueObj => {
|
||||
this.SettingsUpdated = true;
|
||||
this.settings.dates[key] = valueObj;
|
||||
BDFDB.DataUtils.save(this.settings.dates, this, "dates");
|
||||
}
|
||||
}))));
|
||||
|
||||
return settingsItems.flat(10);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
this.forceUpdateAll();
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
forceUpdateAll () {
|
||||
settings = BDFDB.DataUtils.get(this, "settings");
|
||||
choices = BDFDB.DataUtils.get(this, "choices");
|
||||
formats = BDFDB.DataUtils.get(this, "formats");
|
||||
amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
processUserPopout (e) {
|
||||
if (e.instance.props.user && e.instance.props.guild && settings.addInUserPopout) {
|
||||
if (e.instance.props.user && e.instance.props.guild && this.settings.places.userPopout) {
|
||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
|
||||
if (index > -1) this.injectDate(e.instance, children, 2, e.instance.props.user, e.instance.props.guild.id);
|
||||
}
|
||||
}
|
||||
|
||||
processAnalyticsContext (e) {
|
||||
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && settings.addInUserProfil) {
|
||||
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && this.settings.places.userProfile) {
|
||||
let renderChildren = e.returnvalue.props.children;
|
||||
e.returnvalue.props.children = (...args) => {
|
||||
let renderedChildren = renderChildren(...args);
|
||||
|
@ -289,40 +186,19 @@ module.exports = (_ => {
|
|||
requestedUsers[guildId][user.id] = [instance];
|
||||
BDFDB.LibraryModules.APIUtils.get(BDFDB.DiscordConstants.Endpoints.GUILD_MEMBER(guildId, user.id)).then(result => {
|
||||
loadedUsers[guildId][user.id] = new Date(result.body.joined_at);
|
||||
for (let queredinstance of requestedUsers[guildId][user.id]) BDFDB.ReactUtils.forceUpdate(queredinstance);
|
||||
for (let queuedInstance of requestedUsers[guildId][user.id]) BDFDB.ReactUtils.forceUpdate(queuedInstance);
|
||||
});
|
||||
}
|
||||
else if (!loadedUsers[guildId][user.id]) requestedUsers[guildId][user.id].push(instance);
|
||||
else {
|
||||
let timestamp = this.getTimestamp(languages[choices.joinedAtDateLang].id, loadedUsers[guildId][user.id]);
|
||||
let timestamp = BDFDB.LibraryComponents.DateInput.format(this.settings.dates.joinedAtDate, loadedUsers[guildId][user.id]);
|
||||
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||
className: BDFDB.disCNS._joinedatdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
|
||||
children: settings.displayText ? this.labels.joined_at.replace("{{time}}", timestamp) : timestamp
|
||||
children: this.settings.general.displayText ? this.labels.joined_at.replace("{{time}}", timestamp) : timestamp
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
getTimestamp (languageId, time) {
|
||||
return BDFDB.StringUtils.formatTime(time, Object.assign({
|
||||
language: languageId,
|
||||
formatString: languageId == "own" && formats.ownFormat
|
||||
}, settings, amounts));
|
||||
}
|
||||
|
||||
cutOffSeconds (timeString) {
|
||||
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
||||
}
|
||||
|
||||
addLeadingZeros (timeString) {
|
||||
let charArray = timeString.split("");
|
||||
let numreg = /[0-9]/;
|
||||
for (let i = 0; i < charArray.length; i++) {
|
||||
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
||||
}
|
||||
|
||||
return charArray.join("");
|
||||
}
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
||||
case "bg": // Bulgarian
|
||||
|
@ -335,7 +211,7 @@ module.exports = (_ => {
|
|||
};
|
||||
case "de": // German
|
||||
return {
|
||||
joined_at: "Beitritt zu {{time}}"
|
||||
joined_at: "Beitritt am {{time}}"
|
||||
};
|
||||
case "el": // Greek
|
||||
return {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name LastMessageDate
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 1.2.0
|
||||
* @version 1.2.1
|
||||
* @description Displays the Last Message Date of a Member for the current Server/DM in the UserPopout and UserModal
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -17,12 +17,12 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "LastMessageDate",
|
||||
"author": "DevilBro",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"description": "Displays the Last Message Date of a Member for the current Server/DM in the UserPopout and UserModal"
|
||||
},
|
||||
"changeLog": {
|
||||
"fixed": {
|
||||
"Settings": "Work again"
|
||||
"improved": {
|
||||
"New Settings": "Changed the Settings Panel for the Plugin, Settings got reset sowwy ~w~"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -74,25 +74,15 @@ module.exports = (_ => {
|
|||
requestedUsers = {};
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addInUserPopout: {value: true, description: "Add in User Popouts"},
|
||||
addInUserProfil: {value: true, description: "Add in User Profile Modal"},
|
||||
displayText: {value: true, description: "Display 'Last Message on' Text in the Timestamp"},
|
||||
displayTime: {value: true, description: "Display the Time in the Timestamp"},
|
||||
displayDate: {value: true, description: "Display the Date in the Timestamp"},
|
||||
cutSeconds: {value: false, description: "Cut off Seconds of the Time"},
|
||||
forceZeros: {value: false, description: "Force leading Zeros"},
|
||||
otherOrder: {value: false, description: "Show the Time before the Date"},
|
||||
useDateInDaysAgo: {value: false, description: "Use the Date instead of 'x days ago' in $daysago Placeholder"}
|
||||
general: {
|
||||
displayText: {value: true, description: "Display '{{presuffix}}' in the Date"}
|
||||
},
|
||||
choices: {
|
||||
lastMessageDateLang: {value: "$discord", description: "Last Message Date Format"}
|
||||
places: {
|
||||
userPopout: {value: true, description: "User Popouts"},
|
||||
userProfile: {value: true, description: "User Profile Modal"}
|
||||
},
|
||||
formats: {
|
||||
ownFormat: {value: "$hour:$minute:$second, $day.$month.$year", description: "Own Format"}
|
||||
},
|
||||
amounts: {
|
||||
maxDaysAgo: {value: 0, min: 0, description: "Maximum Count of Days displayed in the $daysago Placeholder", note: "0 equals no Limit"}
|
||||
dates: {
|
||||
lastMessageDate: {value: {}, description: "Last Message Date"},
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -105,13 +95,6 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
languages = BDFDB.ObjectUtils.deepAssign({
|
||||
own: {
|
||||
name: "Own",
|
||||
id: "own"
|
||||
}
|
||||
}, BDFDB.LanguageUtils.languages);
|
||||
|
||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.DispatchApiUtils, "dirtyDispatch", {after: e => {
|
||||
if (BDFDB.ObjectUtils.is(e.methodArguments[0]) && e.methodArguments[0].type == BDFDB.DiscordConstants.ActionTypes.MESSAGE_CREATE && e.methodArguments[0].message) {
|
||||
let message = e.methodArguments[0].message;
|
||||
|
@ -122,164 +105,79 @@ module.exports = (_ => {
|
|||
}
|
||||
}});
|
||||
|
||||
this.forceUpdateAll();
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
onStop () {
|
||||
this.forceUpdateAll();
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
getSettingsPanel (collapseStates = {}) {
|
||||
let settingsPanel, settingsItems = [];
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Settings",
|
||||
let settingsPanel;
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
|
||||
collapseStates: collapseStates,
|
||||
children: Object.keys(settings).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["settings", key],
|
||||
label: this.defaults.settings[key].description,
|
||||
value: settings[key],
|
||||
onChange: (value, instance) => {
|
||||
settings[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
||||
}
|
||||
}))
|
||||
}));
|
||||
children: _ => {
|
||||
let settingsItems = [];
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Format",
|
||||
collapseStates: collapseStates,
|
||||
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Select",
|
||||
plugin: this,
|
||||
keys: ["choices", key],
|
||||
label: this.defaults.choices[key].description,
|
||||
basis: "70%",
|
||||
value: choices[key],
|
||||
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value: id, label: lang.name}})),
|
||||
searchable: true,
|
||||
optionRenderer: lang => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
basis: "40%",
|
||||
children: lang.label
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
basis: "60%",
|
||||
children: this.getTimestamp(languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
},
|
||||
valueRenderer: lang => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
shrink: 0,
|
||||
children: lang.label
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 1,
|
||||
shrink: 0,
|
||||
basis: "70%",
|
||||
children: this.getTimestamp(languages[lang.value].id)
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(formats).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["formats", key],
|
||||
label: this.defaults.formats[key].description,
|
||||
basis: "70%",
|
||||
value: formats[key],
|
||||
onChange: (value, instance) => {
|
||||
formats[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
||||
}
|
||||
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
})).concat(Object.keys(amounts).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "TextInput",
|
||||
childProps: {
|
||||
type: "number"
|
||||
},
|
||||
plugin: this,
|
||||
keys: ["amounts", key],
|
||||
label: this.defaults.amounts[key].description,
|
||||
note: this.defaults.amounts[key].note,
|
||||
basis: "20%",
|
||||
min: this.defaults.amounts[key].min,
|
||||
max: this.defaults.amounts[key].max,
|
||||
value: amounts[key]
|
||||
})))
|
||||
}));
|
||||
settingsItems.push(Object.keys(this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["general", key],
|
||||
label: key == "displayText" ? this.defaults.general[key].description.replace("{{presuffix}}", this.labels.last_message.replace("{{time}}", "").trim()) : this.defaults.general[key].description,
|
||||
value: this.settings.general[key]
|
||||
})));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Placeholder Guide",
|
||||
collapseStates: collapseStates,
|
||||
children: [
|
||||
"$hour will be replaced with the hour of the date",
|
||||
"$minute will be replaced with the minutes of the date",
|
||||
"$second will be replaced with the seconds of the date",
|
||||
"$msecond will be replaced with the milliseconds of the date",
|
||||
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
||||
"$year will be replaced with the year of the date",
|
||||
"$yearS will be replaced with the year in short form",
|
||||
"$month will be replaced with the month of the date",
|
||||
"$day will be replaced with the day of the date",
|
||||
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
||||
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
||||
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
||||
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
|
||||
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
|
||||
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
|
||||
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
|
||||
children: string
|
||||
}))
|
||||
}));
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
}));
|
||||
|
||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
||||
title: "Add Date in:",
|
||||
children: Object.keys(this.defaults.places).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["places", key],
|
||||
label: this.defaults.places[key].description,
|
||||
value: this.settings.places[key]
|
||||
}))
|
||||
}));
|
||||
|
||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
}));
|
||||
|
||||
settingsItems.push(Object.keys(this.defaults.dates).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.DateInput, Object.assign({}, this.settings.dates[key], {
|
||||
label: this.defaults.dates[key].description,
|
||||
prefix: _ => (this.settings.general.displayText && this.labels.last_message.split("{{time}}")[0] || "").trim(),
|
||||
suffix: _ => (this.settings.general.displayText && this.labels.last_message.split("{{time}}")[1] || "").trim(),
|
||||
onChange: valueObj => {
|
||||
this.SettingsUpdated = true;
|
||||
this.settings.dates[key] = valueObj;
|
||||
BDFDB.DataUtils.save(this.settings.dates, this, "dates");
|
||||
}
|
||||
}))));
|
||||
|
||||
return settingsItems.flat(10);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
this.forceUpdateAll();
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
forceUpdateAll () {
|
||||
settings = BDFDB.DataUtils.get(this, "settings");
|
||||
choices = BDFDB.DataUtils.get(this, "choices");
|
||||
formats = BDFDB.DataUtils.get(this, "formats");
|
||||
amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||
|
||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
processUserPopout (e) {
|
||||
if (e.instance.props.user && settings.addInUserPopout) {
|
||||
if (e.instance.props.user && e.instance.props.guild && this.settings.places.userPopout) {
|
||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
|
||||
if (index > -1) this.injectDate(e.instance, children, 2, e.instance.props.user, e.instance.props.guild && e.instance.props.guild.id);
|
||||
if (index > -1) this.injectDate(e.instance, children, 2, e.instance.props.user, e.instance.props.guild.id);
|
||||
}
|
||||
}
|
||||
|
||||
processAnalyticsContext (e) {
|
||||
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && settings.addInUserProfil) {
|
||||
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && this.settings.places.userProfile) {
|
||||
let renderChildren = e.returnvalue.props.children;
|
||||
e.returnvalue.props.children = (...args) => {
|
||||
let renderedChildren = renderChildren(...args);
|
||||
|
@ -311,45 +209,24 @@ module.exports = (_ => {
|
|||
}
|
||||
}
|
||||
else loadedUsers[guildId][user.id] = null;
|
||||
for (let queredinstance of requestedUsers[guildId][user.id]) BDFDB.ReactUtils.forceUpdate(queredinstance);
|
||||
for (let queuedInstance of requestedUsers[guildId][user.id]) BDFDB.ReactUtils.forceUpdate(queuedInstance);
|
||||
}
|
||||
else {
|
||||
delete requestedUsers[guildId][user.id];
|
||||
BDFDB.TimeUtils.timeout(_ => {this.injectDate(instance, children, index, user);}, result.body.retry_after + 500);
|
||||
BDFDB.TimeUtils.timeout(_ => this.injectDate(instance, children, index, user), result.body.retry_after + 500);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (loadedUsers[guildId][user.id] === undefined) requestedUsers[guildId][user.id].push(instance);
|
||||
else {
|
||||
let timestamp = loadedUsers[guildId][user.id] ? this.getTimestamp(languages[choices.lastMessageDateLang].id, loadedUsers[guildId][user.id]) : "---";
|
||||
let timestamp = loadedUsers[guildId][user.id] ? BDFDB.LibraryComponents.DateInput.format(this.settings.dates.lastMessageDate, loadedUsers[guildId][user.id]) : "---";
|
||||
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||
className: BDFDB.disCNS._lastmessagedatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
|
||||
children: settings.displayText ? this.labels.last_message.replace("{{time}}", timestamp) : timestamp
|
||||
children: this.settings.general.displayText ? this.labels.last_message.replace("{{time}}", timestamp) : timestamp
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
getTimestamp (languageId, time) {
|
||||
return BDFDB.StringUtils.formatTime(time, Object.assign({
|
||||
language: languageId,
|
||||
formatString: languageId == "own" && formats.ownFormat
|
||||
}, settings, amounts));
|
||||
}
|
||||
|
||||
cutOffSeconds (timeString) {
|
||||
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
||||
}
|
||||
|
||||
addLeadingZeros (timeString) {
|
||||
let charArray = timeString.split("");
|
||||
let numreg = /[0-9]/;
|
||||
for (let i = 0; i < charArray.length; i++) {
|
||||
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
||||
}
|
||||
|
||||
return charArray.join("");
|
||||
}
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
||||
case "bg": // Bulgarian
|
||||
|
|
Loading…
Reference in New Issue