This commit is contained in:
Mirco Wittrien 2023-03-28 17:24:34 +02:00
parent 1039514eb2
commit 88243f1e99
3 changed files with 10 additions and 22 deletions

View File

@ -2,7 +2,7 @@
* @name BDFDB
* @author DevilBro
* @authorId 278543574059057154
* @version 3.2.0
* @version 3.2.1
* @description Required Library for DevilBro's Plugins
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -4091,19 +4091,7 @@ module.exports = (_ => {
if (!url || typeof url != "string") return;
let {callback, cIndex} = args[1] && typeof args[1] == "function" ? {callback: args[1], cIndex: 1} : (args[2] && typeof args[2] == "function" ? {callback: args[2], cIndex: 2} : {callback: null, cIndex: -1});
if (typeof callback != "function") return;
let config = args[0] && typeof args[0] == "object" ? args[0] : (args[1] && typeof args[1] == "object" && args[1]);
let timeoutMs = config && !isNaN(parseInt(config.timeout)) && config.timeout > 0 ? config.timeout : 600000;
let timedout = false, timeout = BDFDB.TimeUtils.timeout(_ => {
timedout = true;
callback(`Request Timeout after ${timeoutMs}ms`, null)
}, timeoutMs);
Internal.LibraryModules.FileRequestUtils.getFileData(url).then(buffer => {
BDFDB.TimeUtils.clear(timeout);
if (timedout) return;
callback(null, buffer);
});
Internal.LibraryModules.FileRequestUtils.getFileData(url).then(buffer => callback(null, buffer)).catch(error => callback(error, null));
};
BDFDB.DiscordUtils.getSetting = function (category, key) {
if (!category || !key) return;

View File

@ -2,7 +2,7 @@
* @name PluginRepo
* @author DevilBro
* @authorId 278543574059057154
* @version 2.4.6
* @version 2.5.0
* @description Allows you to download all Plugins from BD's Website within Discord
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -484,7 +484,7 @@ module.exports = (_ => {
this.props.downloading = true;
let loadingToast = BDFDB.NotificationUtils.toast(`${BDFDB.LanguageUtils.LibraryStringsFormat("loading", this.props.data.name)} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {timeout: 0, ellipsis: true});
let autoloadKey = this.props.data.state == pluginStates.OUTDATED ? "startUpdated" : "startDownloaded";
BDFDB.DiscordUtils.requestFileData(this.props.data.rawSourceUrl, {timeout: 10000}, (error, buffer) => {
BDFDB.DiscordUtils.requestFileData(this.props.data.rawSourceUrl, (error, buffer) => {
if (error || !buffer) {
delete this.props.downloading;
loadingToast.close();
@ -756,7 +756,7 @@ module.exports = (_ => {
delete plugin.release_date;
delete plugin.latest_source_url;
delete plugin.thumbnail_url;
BDFDB.DiscordUtils.requestFileData(plugin.rawSourceUrl, {timeout: 10000}, (error, buffer) => {
BDFDB.DiscordUtils.requestFileData(plugin.rawSourceUrl, (error, buffer) => {
if (error || !buffer) plugin.failed = true;
else {
let body = Buffer.from(buffer).toString();

View File

@ -2,7 +2,7 @@
* @name ThemeRepo
* @author DevilBro
* @authorId 278543574059057154
* @version 2.4.9
* @version 2.5.0
* @description Allows you to download all Themes from BD's Website within Discord
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -632,7 +632,7 @@ module.exports = (_ => {
this.props.downloading = true;
let loadingToast = BDFDB.NotificationUtils.toast(`${BDFDB.LanguageUtils.LibraryStringsFormat("loading", this.props.data.name)} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {timeout: 0, ellipsis: true});
let autoloadKey = this.props.data.state == themeStates ? "startUpdated" : "startDownloaded";
BDFDB.DiscordUtils.requestFileData(this.props.data.rawSourceUrl, {timeout: 10000}, (error, buffer) => {
BDFDB.DiscordUtils.requestFileData(this.props.data.rawSourceUrl, (error, buffer) => {
if (error || !buffer) {
delete this.props.downloading;
loadingToast.close();
@ -885,7 +885,7 @@ module.exports = (_ => {
});
}
BDFDB.DiscordUtils.requestFileData("https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/_res/GeneratorList.txt", {timeout: 10000}, (error, buffer) => {
BDFDB.DiscordUtils.requestFileData("https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/_res/GeneratorList.txt", (error, buffer) => {
let body = !error && buffer && Buffer.from(buffer).toString();
if (body) for (let id of body.replace(/[\r\t]/g, "").split(" ").map(n => parseInt(n)).filter(n => n != null)) {
let theme = grabbedThemes.find(t => t.id == id);
@ -893,7 +893,7 @@ module.exports = (_ => {
}
});
BDFDB.DiscordUtils.requestFileData(document.querySelector("head link[rel='stylesheet'][integrity]").href, {timeout: 10000}, (error, buffer) => {
BDFDB.DiscordUtils.requestFileData(document.querySelector("head link[rel='stylesheet'][integrity]").href, (error, buffer) => {
let nativeCSS = !error && buffer && Buffer.from(buffer).toString();
if (nativeCSS) {
let theme = BDFDB.DiscordUtils.getTheme();
@ -919,7 +919,7 @@ module.exports = (_ => {
delete theme.release_date;
delete theme.latest_source_url;
delete theme.thumbnail_url;
BDFDB.DiscordUtils.requestFileData(theme.rawSourceUrl, {timeout: 10000}, (error, buffer) => {
BDFDB.DiscordUtils.requestFileData(theme.rawSourceUrl, (error, buffer) => {
if (error || !buffer) theme.failed = true;
else {
let body = Buffer.from(buffer).toString();