mirror of
https://github.com/Lightcord/Lightcord.git
synced 2025-04-12 00:55:40 +02:00
Sync with rauenzi/BetterDiscordApp 6fa2960
This commit is contained in:
parent
b0ecc2a669
commit
d854e057c4
File diff suppressed because one or more lines are too long
2
BetterDiscordApp/js/main.min.js
vendored
2
BetterDiscordApp/js/main.min.js
vendored
File diff suppressed because one or more lines are too long
@ -247,8 +247,7 @@ Core.prototype.checkForGuilds = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Core.prototype.injectExternals = async function() {
|
Core.prototype.injectExternals = async function() {
|
||||||
await DOM.addScript("ace-script", "https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js");
|
// No externals
|
||||||
if (window.require.original) window.require = window.require.original;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Core.prototype.initSettings = function () {
|
Core.prototype.initSettings = function () {
|
||||||
|
@ -71,6 +71,24 @@ export default class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format strings with placeholders (`{{placeholder}}`) into full strings.
|
||||||
|
* Quick example: `PluginUtilities.formatString("Hello, {{user}}", {user: "Zerebos"})`
|
||||||
|
* would return "Hello, Zerebos".
|
||||||
|
* @param {string} string - string to format
|
||||||
|
* @param {object} values - object literal of placeholders to replacements
|
||||||
|
* @returns {string} the properly formatted string
|
||||||
|
*/
|
||||||
|
static formatString(string, values) {
|
||||||
|
for (const val in values) {
|
||||||
|
let replacement = values[val];
|
||||||
|
if (Array.isArray(replacement)) replacement = JSON.stringify(replacement);
|
||||||
|
if (typeof(replacement) === "object" && replacement !== null) replacement = replacement.toString();
|
||||||
|
string = string.replace(new RegExp(`{{${val}}}`, "g"), replacement);
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
static escape(s) {
|
static escape(s) {
|
||||||
return s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
return s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user