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] {
|
[REPLACE_CLASS_dateinputpreviewsuffix] {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
[REPLACE_CLASS_dateinputpreviewprefix] {
|
[REPLACE_CLASS_dateinputpreviewprefix]:not(:empty) {
|
||||||
margin-right: 6px;
|
margin-right: 6px;
|
||||||
}
|
}
|
||||||
[REPLACE_CLASS_dateinputpreviewsuffix] {
|
[REPLACE_CLASS_dateinputpreviewsuffix]:not(:empty) {
|
||||||
margin-left: 6px;
|
margin-left: 6px;
|
||||||
}
|
}
|
||||||
[REPLACE_CLASS_dateinputfield] {
|
[REPLACE_CLASS_dateinputfield] {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @name CreationDate
|
* @name CreationDate
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 1.4.0
|
* @version 1.4.1
|
||||||
* @description Displays the Creation Date of an Account in the UserPopout and UserModal
|
* @description Displays the Creation Date of an Account in the UserPopout and UserModal
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -17,12 +17,12 @@ module.exports = (_ => {
|
||||||
"info": {
|
"info": {
|
||||||
"name": "CreationDate",
|
"name": "CreationDate",
|
||||||
"author": "DevilBro",
|
"author": "DevilBro",
|
||||||
"version": "1.4.0",
|
"version": "1.4.1",
|
||||||
"description": "Displays the Creation Date of an Account in the UserPopout and UserModal"
|
"description": "Displays the Creation Date of an Account in the UserPopout and UserModal"
|
||||||
},
|
},
|
||||||
"changeLog": {
|
"changeLog": {
|
||||||
"fixed": {
|
"improved": {
|
||||||
"Settings": "Work again"
|
"New Settings": "Changed the Settings Panel for the Plugin, Settings got reset sowwy ~w~"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -64,32 +64,19 @@ module.exports = (_ => {
|
||||||
template.content.firstElementChild.querySelector("a").addEventListener("click", this.downloadLibrary);
|
template.content.firstElementChild.querySelector("a").addEventListener("click", this.downloadLibrary);
|
||||||
return template.content.firstElementChild;
|
return template.content.firstElementChild;
|
||||||
}
|
}
|
||||||
} : (([Plugin, BDFDB]) => {
|
} : (([Plugin, BDFDB]) => {
|
||||||
var languages;
|
|
||||||
var settings = {}, choices = {}, formats = {}, amounts = {};
|
|
||||||
|
|
||||||
return class CreationDate extends Plugin {
|
return class CreationDate extends Plugin {
|
||||||
onLoad () {
|
onLoad () {
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
settings: {
|
general: {
|
||||||
addInUserPopout: {value: true, description: "Add in User Popouts"},
|
displayText: {value: true, description: "Display '{{presuffix}}' in the Date"}
|
||||||
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"}
|
|
||||||
},
|
},
|
||||||
choices: {
|
places: {
|
||||||
creationDateLang: {value: "$discord", description: "Creation Date Format"}
|
userPopout: {value: true, description: "User Popouts"},
|
||||||
|
userProfile: {value: true, description: "User Profile Modal"}
|
||||||
},
|
},
|
||||||
formats: {
|
dates: {
|
||||||
ownFormat: {value: "$hour:$minute:$second, $day.$month.$year", description: "Own Format"}
|
creationDate: {value: {}, description: "Creation Date"},
|
||||||
},
|
|
||||||
amounts: {
|
|
||||||
maxDaysAgo: {value: 0, min: 0, description: "Maximum Count of Days displayed in the $daysago Placeholder", note: "0 equals no Limit"}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,171 +90,79 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onStart () {
|
onStart () {
|
||||||
languages = BDFDB.ObjectUtils.deepAssign({
|
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||||
own: {
|
|
||||||
"name": "Own",
|
|
||||||
id: "own"
|
|
||||||
}
|
|
||||||
}, BDFDB.LanguageUtils.languages);
|
|
||||||
|
|
||||||
this.forceUpdateAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onStop () {
|
onStop () {
|
||||||
this.forceUpdateAll();
|
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSettingsPanel (collapseStates = {}) {
|
getSettingsPanel (collapseStates = {}) {
|
||||||
let settingsPanel, settingsItems = [];
|
let settingsPanel;
|
||||||
|
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
|
||||||
title: "Settings",
|
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: Object.keys(settings).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
children: _ => {
|
||||||
type: "Switch",
|
let settingsItems = [];
|
||||||
plugin: this,
|
|
||||||
keys: ["settings", key],
|
settingsItems.push(Object.keys(this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
label: this.defaults.settings[key].description,
|
type: "Switch",
|
||||||
value: settings[key],
|
plugin: this,
|
||||||
onChange: (value, instance) => {
|
keys: ["general", key],
|
||||||
settings[key] = value;
|
label: key == "displayText" ? this.defaults.general[key].description.replace("{{presuffix}}", this.labels.created_at.replace("{{time}}", "").trim()) : this.defaults.general[key].description,
|
||||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
value: this.settings.general[key]
|
||||||
}
|
})));
|
||||||
}))
|
|
||||||
}));
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
|
className: BDFDB.disCN.marginbottom8
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
}));
|
||||||
title: "Format",
|
|
||||||
collapseStates: collapseStates,
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
||||||
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
title: "Add Date in:",
|
||||||
type: "Select",
|
children: Object.keys(this.defaults.places).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
plugin: this,
|
type: "Switch",
|
||||||
keys: ["choices", key],
|
plugin: this,
|
||||||
label: this.defaults.choices[key].description,
|
keys: ["places", key],
|
||||||
basis: "70%",
|
label: this.defaults.places[key].description,
|
||||||
value: choices[key],
|
value: this.settings.places[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, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
className: BDFDB.disCN.marginbottom8
|
||||||
children: [
|
}));
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
|
||||||
grow: 0,
|
settingsItems.push(Object.keys(this.defaults.dates).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.DateInput, Object.assign({}, this.settings.dates[key], {
|
||||||
shrink: 0,
|
label: this.defaults.dates[key].description,
|
||||||
basis: "40%",
|
prefix: _ => (this.settings.general.displayText && this.labels.created_at.split("{{time}}")[0] || "").trim(),
|
||||||
children: lang.label
|
suffix: _ => (this.settings.general.displayText && this.labels.created_at.split("{{time}}")[1] || "").trim(),
|
||||||
}),
|
onChange: valueObj => {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
this.SettingsUpdated = true;
|
||||||
grow: 0,
|
this.settings.dates[key] = valueObj;
|
||||||
shrink: 0,
|
BDFDB.DataUtils.save(this.settings.dates, this, "dates");
|
||||||
basis: "60%",
|
}
|
||||||
children: this.getTimestamp(languages[lang.value].id)
|
}))));
|
||||||
})
|
|
||||||
]
|
return settingsItems.flat(10);
|
||||||
});
|
}
|
||||||
},
|
});
|
||||||
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(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
|
|
||||||
}))
|
|
||||||
}));
|
|
||||||
|
|
||||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onSettingsClosed () {
|
onSettingsClosed () {
|
||||||
if (this.SettingsUpdated) {
|
if (this.SettingsUpdated) {
|
||||||
delete 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) {
|
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"});
|
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
|
||||||
if (index > -1) this.injectDate(children, 2, e.instance.props.user);
|
if (index > -1) this.injectDate(children, 2, e.instance.props.user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processAnalyticsContext (e) {
|
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;
|
let renderChildren = e.returnvalue.props.children;
|
||||||
e.returnvalue.props.children = (...args) => {
|
e.returnvalue.props.children = (...args) => {
|
||||||
let renderedChildren = renderChildren(...args);
|
let renderedChildren = renderChildren(...args);
|
||||||
|
@ -279,33 +174,13 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
injectDate (children, index, user) {
|
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, {
|
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||||
className: BDFDB.disCNS._creationdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
|
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 () {
|
setLabelsByLanguage () {
|
||||||
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
||||||
case "bg": // Bulgarian
|
case "bg": // Bulgarian
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @name JoinedAtDate
|
* @name JoinedAtDate
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 1.2.5
|
* @version 1.2.6
|
||||||
* @description Displays the Joined At Date of a Member in the UserPopout and UserModal
|
* @description Displays the Joined At Date of a Member in the UserPopout and UserModal
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -17,12 +17,12 @@ module.exports = (_ => {
|
||||||
"info": {
|
"info": {
|
||||||
"name": "JoinedAtDate",
|
"name": "JoinedAtDate",
|
||||||
"author": "DevilBro",
|
"author": "DevilBro",
|
||||||
"version": "1.2.5",
|
"version": "1.2.6",
|
||||||
"description": "Displays the Joined At Date of a Member in the UserPopout and UserModal"
|
"description": "Displays the Joined At Date of a Member in the UserPopout and UserModal"
|
||||||
},
|
},
|
||||||
"changeLog": {
|
"changeLog": {
|
||||||
"fixed": {
|
"improved": {
|
||||||
"Settings": "Work again"
|
"New Settings": "Changed the Settings Panel for the Plugin, Settings got reset sowwy ~w~"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -65,8 +65,7 @@ module.exports = (_ => {
|
||||||
return template.content.firstElementChild;
|
return template.content.firstElementChild;
|
||||||
}
|
}
|
||||||
} : (([Plugin, BDFDB]) => {
|
} : (([Plugin, BDFDB]) => {
|
||||||
var loadedUsers, requestedUsers, languages;
|
var loadedUsers, requestedUsers;
|
||||||
var settings = {}, choices = {}, formats = {}, amounts = {};
|
|
||||||
|
|
||||||
return class JoinedAtDate extends Plugin {
|
return class JoinedAtDate extends Plugin {
|
||||||
onLoad () {
|
onLoad () {
|
||||||
|
@ -74,25 +73,15 @@ module.exports = (_ => {
|
||||||
requestedUsers = {};
|
requestedUsers = {};
|
||||||
|
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
settings: {
|
general: {
|
||||||
addInUserPopout: {value: true, description: "Add in User Popouts"},
|
displayText: {value: true, description: "Display '{{presuffix}}' in the Date"}
|
||||||
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"}
|
|
||||||
},
|
},
|
||||||
choices: {
|
places: {
|
||||||
joinedAtDateLang: {value: "$discord", description: "Joined At Date Format"}
|
userPopout: {value: true, description: "User Popouts"},
|
||||||
|
userProfile: {value: true, description: "User Profile Modal"}
|
||||||
},
|
},
|
||||||
formats: {
|
dates: {
|
||||||
ownFormat: {value: "$hour:$minute:$second, $day.$month.$year", description: "Own Format"}
|
joinedAtDate: {value: {}, description: "Joined at Date"},
|
||||||
},
|
|
||||||
amounts: {
|
|
||||||
maxDaysAgo: {value: 0, min: 0, description: "Maximum Count of Days displayed in the $daysago Placeholder", note: "0 equals no Limit"}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,171 +94,79 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onStart () {
|
onStart () {
|
||||||
languages = BDFDB.ObjectUtils.deepAssign({
|
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||||
own: {
|
|
||||||
name: "Own",
|
|
||||||
id: "own"
|
|
||||||
}
|
|
||||||
}, BDFDB.LanguageUtils.languages);
|
|
||||||
|
|
||||||
this.forceUpdateAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onStop () {
|
onStop () {
|
||||||
this.forceUpdateAll();
|
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSettingsPanel (collapseStates = {}) {
|
getSettingsPanel (collapseStates = {}) {
|
||||||
let settingsPanel, settingsItems = [];
|
let settingsPanel;
|
||||||
|
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
|
||||||
title: "Settings",
|
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: Object.keys(settings).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
children: _ => {
|
||||||
type: "Switch",
|
let settingsItems = [];
|
||||||
plugin: this,
|
|
||||||
keys: ["settings", key],
|
settingsItems.push(Object.keys(this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
label: this.defaults.settings[key].description,
|
type: "Switch",
|
||||||
value: settings[key],
|
plugin: this,
|
||||||
onChange: (value, instance) => {
|
keys: ["general", key],
|
||||||
settings[key] = value;
|
label: key == "displayText" ? this.defaults.general[key].description.replace("{{presuffix}}", this.labels.joined_at.replace("{{time}}", "").trim()) : this.defaults.general[key].description,
|
||||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
value: this.settings.general[key]
|
||||||
}
|
})));
|
||||||
}))
|
|
||||||
}));
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
|
className: BDFDB.disCN.marginbottom8
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
}));
|
||||||
title: "Format",
|
|
||||||
collapseStates: collapseStates,
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
||||||
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
title: "Add Date in:",
|
||||||
type: "Select",
|
children: Object.keys(this.defaults.places).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
plugin: this,
|
type: "Switch",
|
||||||
keys: ["choices", key],
|
plugin: this,
|
||||||
label: this.defaults.choices[key].description,
|
keys: ["places", key],
|
||||||
basis: "70%",
|
label: this.defaults.places[key].description,
|
||||||
value: choices[key],
|
value: this.settings.places[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, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
className: BDFDB.disCN.marginbottom8
|
||||||
children: [
|
}));
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
|
||||||
grow: 0,
|
settingsItems.push(Object.keys(this.defaults.dates).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.DateInput, Object.assign({}, this.settings.dates[key], {
|
||||||
shrink: 0,
|
label: this.defaults.dates[key].description,
|
||||||
basis: "40%",
|
prefix: _ => (this.settings.general.displayText && this.labels.joined_at.split("{{time}}")[0] || "").trim(),
|
||||||
children: lang.label
|
suffix: _ => (this.settings.general.displayText && this.labels.joined_at.split("{{time}}")[1] || "").trim(),
|
||||||
}),
|
onChange: valueObj => {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
this.SettingsUpdated = true;
|
||||||
grow: 0,
|
this.settings.dates[key] = valueObj;
|
||||||
shrink: 0,
|
BDFDB.DataUtils.save(this.settings.dates, this, "dates");
|
||||||
basis: "60%",
|
}
|
||||||
children: this.getTimestamp(languages[lang.value].id)
|
}))));
|
||||||
})
|
|
||||||
]
|
return settingsItems.flat(10);
|
||||||
});
|
}
|
||||||
},
|
});
|
||||||
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(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
|
|
||||||
}))
|
|
||||||
}));
|
|
||||||
|
|
||||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onSettingsClosed () {
|
onSettingsClosed () {
|
||||||
if (this.SettingsUpdated) {
|
if (this.SettingsUpdated) {
|
||||||
delete 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) {
|
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"});
|
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);
|
if (index > -1) this.injectDate(e.instance, children, 2, e.instance.props.user, e.instance.props.guild.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processAnalyticsContext (e) {
|
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;
|
let renderChildren = e.returnvalue.props.children;
|
||||||
e.returnvalue.props.children = (...args) => {
|
e.returnvalue.props.children = (...args) => {
|
||||||
let renderedChildren = renderChildren(...args);
|
let renderedChildren = renderChildren(...args);
|
||||||
|
@ -289,40 +186,19 @@ module.exports = (_ => {
|
||||||
requestedUsers[guildId][user.id] = [instance];
|
requestedUsers[guildId][user.id] = [instance];
|
||||||
BDFDB.LibraryModules.APIUtils.get(BDFDB.DiscordConstants.Endpoints.GUILD_MEMBER(guildId, user.id)).then(result => {
|
BDFDB.LibraryModules.APIUtils.get(BDFDB.DiscordConstants.Endpoints.GUILD_MEMBER(guildId, user.id)).then(result => {
|
||||||
loadedUsers[guildId][user.id] = new Date(result.body.joined_at);
|
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 if (!loadedUsers[guildId][user.id]) requestedUsers[guildId][user.id].push(instance);
|
||||||
else {
|
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, {
|
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||||
className: BDFDB.disCNS._joinedatdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
|
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 () {
|
setLabelsByLanguage () {
|
||||||
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
||||||
case "bg": // Bulgarian
|
case "bg": // Bulgarian
|
||||||
|
@ -335,7 +211,7 @@ module.exports = (_ => {
|
||||||
};
|
};
|
||||||
case "de": // German
|
case "de": // German
|
||||||
return {
|
return {
|
||||||
joined_at: "Beitritt zu {{time}}"
|
joined_at: "Beitritt am {{time}}"
|
||||||
};
|
};
|
||||||
case "el": // Greek
|
case "el": // Greek
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @name LastMessageDate
|
* @name LastMessageDate
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @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
|
* @description Displays the Last Message Date of a Member for the current Server/DM in the UserPopout and UserModal
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -17,12 +17,12 @@ module.exports = (_ => {
|
||||||
"info": {
|
"info": {
|
||||||
"name": "LastMessageDate",
|
"name": "LastMessageDate",
|
||||||
"author": "DevilBro",
|
"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"
|
"description": "Displays the Last Message Date of a Member for the current Server/DM in the UserPopout and UserModal"
|
||||||
},
|
},
|
||||||
"changeLog": {
|
"changeLog": {
|
||||||
"fixed": {
|
"improved": {
|
||||||
"Settings": "Work again"
|
"New Settings": "Changed the Settings Panel for the Plugin, Settings got reset sowwy ~w~"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -74,25 +74,15 @@ module.exports = (_ => {
|
||||||
requestedUsers = {};
|
requestedUsers = {};
|
||||||
|
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
settings: {
|
general: {
|
||||||
addInUserPopout: {value: true, description: "Add in User Popouts"},
|
displayText: {value: true, description: "Display '{{presuffix}}' in the Date"}
|
||||||
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"}
|
|
||||||
},
|
},
|
||||||
choices: {
|
places: {
|
||||||
lastMessageDateLang: {value: "$discord", description: "Last Message Date Format"}
|
userPopout: {value: true, description: "User Popouts"},
|
||||||
|
userProfile: {value: true, description: "User Profile Modal"}
|
||||||
},
|
},
|
||||||
formats: {
|
dates: {
|
||||||
ownFormat: {value: "$hour:$minute:$second, $day.$month.$year", description: "Own Format"}
|
lastMessageDate: {value: {}, description: "Last Message Date"},
|
||||||
},
|
|
||||||
amounts: {
|
|
||||||
maxDaysAgo: {value: 0, min: 0, description: "Maximum Count of Days displayed in the $daysago Placeholder", note: "0 equals no Limit"}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,13 +95,6 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onStart () {
|
onStart () {
|
||||||
languages = BDFDB.ObjectUtils.deepAssign({
|
|
||||||
own: {
|
|
||||||
name: "Own",
|
|
||||||
id: "own"
|
|
||||||
}
|
|
||||||
}, BDFDB.LanguageUtils.languages);
|
|
||||||
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.DispatchApiUtils, "dirtyDispatch", {after: e => {
|
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) {
|
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;
|
let message = e.methodArguments[0].message;
|
||||||
|
@ -122,164 +105,79 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
|
|
||||||
this.forceUpdateAll();
|
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
onStop () {
|
onStop () {
|
||||||
this.forceUpdateAll();
|
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSettingsPanel (collapseStates = {}) {
|
getSettingsPanel (collapseStates = {}) {
|
||||||
let settingsPanel, settingsItems = [];
|
let settingsPanel;
|
||||||
|
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
|
||||||
title: "Settings",
|
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: Object.keys(settings).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
children: _ => {
|
||||||
type: "Switch",
|
let settingsItems = [];
|
||||||
plugin: this,
|
|
||||||
keys: ["settings", key],
|
settingsItems.push(Object.keys(this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
label: this.defaults.settings[key].description,
|
type: "Switch",
|
||||||
value: settings[key],
|
plugin: this,
|
||||||
onChange: (value, instance) => {
|
keys: ["general", key],
|
||||||
settings[key] = value;
|
label: key == "displayText" ? this.defaults.general[key].description.replace("{{presuffix}}", this.labels.last_message.replace("{{time}}", "").trim()) : this.defaults.general[key].description,
|
||||||
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: "BDFDB_SettingsPanel", up: true}), {name: "BDFDB_Select", all: true, noCopies: true}));
|
value: this.settings.general[key]
|
||||||
}
|
})));
|
||||||
}))
|
|
||||||
}));
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
|
className: BDFDB.disCN.marginbottom8
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
}));
|
||||||
title: "Format",
|
|
||||||
collapseStates: collapseStates,
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
||||||
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
title: "Add Date in:",
|
||||||
type: "Select",
|
children: Object.keys(this.defaults.places).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
plugin: this,
|
type: "Switch",
|
||||||
keys: ["choices", key],
|
plugin: this,
|
||||||
label: this.defaults.choices[key].description,
|
keys: ["places", key],
|
||||||
basis: "70%",
|
label: this.defaults.places[key].description,
|
||||||
value: choices[key],
|
value: this.settings.places[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, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
className: BDFDB.disCN.marginbottom8
|
||||||
children: [
|
}));
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
|
||||||
grow: 0,
|
settingsItems.push(Object.keys(this.defaults.dates).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.DateInput, Object.assign({}, this.settings.dates[key], {
|
||||||
shrink: 0,
|
label: this.defaults.dates[key].description,
|
||||||
basis: "40%",
|
prefix: _ => (this.settings.general.displayText && this.labels.last_message.split("{{time}}")[0] || "").trim(),
|
||||||
children: lang.label
|
suffix: _ => (this.settings.general.displayText && this.labels.last_message.split("{{time}}")[1] || "").trim(),
|
||||||
}),
|
onChange: valueObj => {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
this.SettingsUpdated = true;
|
||||||
grow: 0,
|
this.settings.dates[key] = valueObj;
|
||||||
shrink: 0,
|
BDFDB.DataUtils.save(this.settings.dates, this, "dates");
|
||||||
basis: "60%",
|
}
|
||||||
children: this.getTimestamp(languages[lang.value].id)
|
}))));
|
||||||
})
|
|
||||||
]
|
return settingsItems.flat(10);
|
||||||
});
|
}
|
||||||
},
|
});
|
||||||
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(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
|
|
||||||
}))
|
|
||||||
}));
|
|
||||||
|
|
||||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onSettingsClosed () {
|
onSettingsClosed () {
|
||||||
if (this.SettingsUpdated) {
|
if (this.SettingsUpdated) {
|
||||||
delete 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) {
|
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"});
|
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) {
|
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;
|
let renderChildren = e.returnvalue.props.children;
|
||||||
e.returnvalue.props.children = (...args) => {
|
e.returnvalue.props.children = (...args) => {
|
||||||
let renderedChildren = renderChildren(...args);
|
let renderedChildren = renderChildren(...args);
|
||||||
|
@ -311,45 +209,24 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else loadedUsers[guildId][user.id] = null;
|
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 {
|
else {
|
||||||
delete requestedUsers[guildId][user.id];
|
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 if (loadedUsers[guildId][user.id] === undefined) requestedUsers[guildId][user.id].push(instance);
|
||||||
else {
|
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, {
|
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||||
className: BDFDB.disCNS._lastmessagedatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
|
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 () {
|
setLabelsByLanguage () {
|
||||||
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
||||||
case "bg": // Bulgarian
|
case "bg": // Bulgarian
|
||||||
|
|
Loading…
Reference in New Issue