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
File diff suppressed because one or more lines are too long
|
@ -247,8 +247,7 @@ Core.prototype.checkForGuilds = function() {
|
|||
};
|
||||
|
||||
Core.prototype.injectExternals = async function() {
|
||||
await DOM.addScript("ace-script", "https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js");
|
||||
if (window.require.original) window.require = window.require.original;
|
||||
// No externals
|
||||
};
|
||||
|
||||
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) {
|
||||
return s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue