repo plugins

This commit is contained in:
Mirco Wittrien 2021-06-15 14:06:15 +02:00
parent e481f64574
commit 580b92ef61
2 changed files with 42 additions and 32 deletions

View File

@ -2,7 +2,7 @@
* @name PluginRepo
* @author DevilBro
* @authorId 278543574059057154
* @version 2.2.5
* @version 2.2.6
* @description Allows you to download all Plugins from BD's Website within Discord
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -17,7 +17,7 @@ module.exports = (_ => {
"info": {
"name": "PluginRepo",
"author": "DevilBro",
"version": "2.2.5",
"version": "2.2.6",
"description": "Allows you to download all Plugins from BD's Website within Discord"
}
};
@ -84,19 +84,16 @@ module.exports = (_ => {
};
const buttonData = {
INSTALLED: {
colorClass: "GREEN",
backgroundColor: "var(--bdfdb-green)",
icon: "CHECKMARK",
text: "USER_SETTINGS_VOICE_INSTALLED_LABEL"
},
OUTDATED: {
colorClass: "RED",
backgroundColor: "var(--bdfdb-red)",
icon: "CLOSE",
text: "outdated"
},
DOWNLOADABLE: {
colorClass: "BRAND",
backgroundColor: "var(--bdfdb-blurple)",
icon: "DOWNLOAD",
text: "download"
@ -440,6 +437,7 @@ module.exports = (_ => {
BDFDB.ReactUtils.createElement(RepoCardDownloadButtonComponent, {
...buttonData[(Object.entries(pluginStates).find(n => n[1] == this.props.data.state) || [])[0]],
installed: this.props.data.state == pluginStates.INSTALLED,
outdated: this.props.data.state == pluginStates.OUTDATED,
onDownload: _ => {
BDFDB.LibraryRequires.request(this.props.data.rawSourceUrl, (error, response, body) => {
if (error) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("download_fail", `Plugin "${this.props.data.name}"`), {type: "danger"});
@ -483,30 +481,37 @@ module.exports = (_ => {
const RepoCardDownloadButtonComponent = class PluginCardDownloadButton extends BdApi.React.Component {
render() {
const backgroundColor = this.props.doDelete ? buttonData.OUTDATED.backgroundColor : this.props.doUpdate ? buttonData.INSTALLED.backgroundColor : this.props.backgroundColor;
return BDFDB.ReactUtils.createElement("button", {
className: BDFDB.disCN.discoverycardbutton,
style: {backgroundColor: this.props.delete ? BDFDB.DiscordConstants.Colors.STATUS_RED : (BDFDB.DiscordConstants.Colors[this.props.backgroundColor] || this.props.backgroundColor)},
style: {backgroundColor: BDFDB.DiscordConstants.Colors[backgroundColor] || backgroundColor},
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.discoverycardstaticon,
width: 16,
height: 16,
name: this.props.delete ? BDFDB.LibraryComponents.SvgIcon.Names.TRASH : BDFDB.LibraryComponents.SvgIcon.Names[this.props.icon]
name: this.props.doDelete ? BDFDB.LibraryComponents.SvgIcon.Names.TRASH : this.props.doUpdate ? BDFDB.LibraryComponents.SvgIcon.Names.DOWNLOAD : BDFDB.LibraryComponents.SvgIcon.Names[this.props.icon]
}),
this.props.delete ? BDFDB.LanguageUtils.LanguageStrings.APPLICATION_CONTEXT_MENU_UNINSTALL : (BDFDB.LanguageUtils.LibraryStringsCheck[this.props.text] ? BDFDB.LanguageUtils.LibraryStrings[this.props.text] : BDFDB.LanguageUtils.LanguageStrings[this.props.text])
this.props.doDelete ? BDFDB.LanguageUtils.LanguageStrings.APPLICATION_CONTEXT_MENU_UNINSTALL : this.props.doUpdate ? BDFDB.LanguageUtils.LanguageStrings.GAME_ACTION_BUTTON_UPDATE : (BDFDB.LanguageUtils.LibraryStringsCheck[this.props.text] ? BDFDB.LanguageUtils.LibraryStrings[this.props.text] : BDFDB.LanguageUtils.LanguageStrings[this.props.text])
],
onClick: _ => {
if (this.props.delete) typeof this.props.onDelete == "function" && this.props.onDelete();
else typeof this.props.onDelete == "function" && this.props.onDownload();
if (this.props.doDelete) typeof this.props.onDelete == "function" && this.props.onDelete();
else typeof this.props.onDownload == "function" && this.props.onDownload();
},
onMouseEnter: this.props.installed && (_ => {
this.props.delete = true;
onMouseEnter: this.props.installed ? (_ => {
this.props.doDelete = true;
BDFDB.ReactUtils.forceUpdate(this);
}),
onMouseLeave: this.props.installed && (_ => {
this.props.delete = false;
}) : this.props.outdated ? (_ => {
this.props.doUpdate = true;
BDFDB.ReactUtils.forceUpdate(this);
})
}) : (_ => {}),
onMouseLeave: this.props.installed ? (_ => {
this.props.doDelete = false;
BDFDB.ReactUtils.forceUpdate(this);
}) : this.props.outdated ? (_ => {
this.props.doUpdate = false;
BDFDB.ReactUtils.forceUpdate(this);
}) : (_ => {})
});
}
};

View File

@ -2,7 +2,7 @@
* @name ThemeRepo
* @author DevilBro
* @authorId 278543574059057154
* @version 2.2.5
* @version 2.2.6
* @description Allows you to download all Themes from BD's Website within Discord
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -17,7 +17,7 @@ module.exports = (_ => {
"info": {
"name": "ThemeRepo",
"author": "DevilBro",
"version": "2.2.5",
"version": "2.2.6",
"description": "Allows you to download all Themes from BD's Website within Discord"
}
};
@ -85,19 +85,16 @@ module.exports = (_ => {
};
const buttonData = {
INSTALLED: {
colorClass: "GREEN",
backgroundColor: "var(--bdfdb-green)",
icon: "CHECKMARK",
text: "USER_SETTINGS_VOICE_INSTALLED_LABEL"
},
OUTDATED: {
colorClass: "RED",
backgroundColor: "var(--bdfdb-red)",
icon: "CLOSE",
text: "outdated"
},
DOWNLOADABLE: {
colorClass: "BRAND",
backgroundColor: "var(--bdfdb-blurple)",
icon: "DOWNLOAD",
text: "download"
@ -869,6 +866,7 @@ module.exports = (_ => {
BDFDB.ReactUtils.createElement(RepoCardDownloadButtonComponent, {
...buttonData[(Object.entries(themeStates).find(n => n[1] == this.props.data.state) || [])[0]],
installed: this.props.data.state == themeStates.INSTALLED,
outdated: this.props.data.state == themeStates.OUTDATED,
onDownload: _ => {
list && BDFDB.LibraryRequires.request(this.props.data.rawSourceUrl, (error, response, body) => {
if (error) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("download_fail", `Theme "${this.props.data.name}"`), {type: "danger"});
@ -902,30 +900,37 @@ module.exports = (_ => {
const RepoCardDownloadButtonComponent = class ThemeCardDownloadButton extends BdApi.React.Component {
render() {
const backgroundColor = this.props.doDelete ? buttonData.OUTDATED.backgroundColor : this.props.doUpdate ? buttonData.INSTALLED.backgroundColor : this.props.backgroundColor;
return BDFDB.ReactUtils.createElement("button", {
className: BDFDB.disCN.discoverycardbutton,
style: {backgroundColor: this.props.delete ? BDFDB.DiscordConstants.Colors.STATUS_RED : (BDFDB.DiscordConstants.Colors[this.props.backgroundColor] || this.props.backgroundColor)},
style: {backgroundColor: BDFDB.DiscordConstants.Colors[backgroundColor] || backgroundColor},
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.discoverycardstaticon,
width: 16,
height: 16,
name: this.props.delete ? BDFDB.LibraryComponents.SvgIcon.Names.TRASH : BDFDB.LibraryComponents.SvgIcon.Names[this.props.icon]
name: this.props.doDelete ? BDFDB.LibraryComponents.SvgIcon.Names.TRASH : this.props.doUpdate ? BDFDB.LibraryComponents.SvgIcon.Names.DOWNLOAD : BDFDB.LibraryComponents.SvgIcon.Names[this.props.icon]
}),
this.props.delete ? BDFDB.LanguageUtils.LanguageStrings.APPLICATION_CONTEXT_MENU_UNINSTALL : (BDFDB.LanguageUtils.LibraryStringsCheck[this.props.text] ? BDFDB.LanguageUtils.LibraryStrings[this.props.text] : BDFDB.LanguageUtils.LanguageStrings[this.props.text])
this.props.doDelete ? BDFDB.LanguageUtils.LanguageStrings.APPLICATION_CONTEXT_MENU_UNINSTALL : this.props.doUpdate ? BDFDB.LanguageUtils.LanguageStrings.GAME_ACTION_BUTTON_UPDATE : (BDFDB.LanguageUtils.LibraryStringsCheck[this.props.text] ? BDFDB.LanguageUtils.LibraryStrings[this.props.text] : BDFDB.LanguageUtils.LanguageStrings[this.props.text])
],
onClick: _ => {
if (this.props.delete) typeof this.props.onDelete == "function" && this.props.onDelete();
else typeof this.props.onDelete == "function" && this.props.onDownload();
if (this.props.doDelete) typeof this.props.onDelete == "function" && this.props.onDelete();
else typeof this.props.onDownload == "function" && this.props.onDownload();
},
onMouseEnter: this.props.installed && (_ => {
this.props.delete = true;
onMouseEnter: this.props.installed ? (_ => {
this.props.doDelete = true;
BDFDB.ReactUtils.forceUpdate(this);
}),
onMouseLeave: this.props.installed && (_ => {
this.props.delete = false;
}) : this.props.outdated ? (_ => {
this.props.doUpdate = true;
BDFDB.ReactUtils.forceUpdate(this);
})
}) : (_ => {}),
onMouseLeave: this.props.installed ? (_ => {
this.props.doDelete = false;
BDFDB.ReactUtils.forceUpdate(this);
}) : this.props.outdated ? (_ => {
this.props.doUpdate = false;
BDFDB.ReactUtils.forceUpdate(this);
}) : (_ => {})
});
}
};