update
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @name EditRoles
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 1.0.9
|
||||
* @version 1.1.2
|
||||
* @description Allows you to locally edit Roles
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
@@ -13,25 +13,16 @@
|
||||
*/
|
||||
|
||||
module.exports = (_ => {
|
||||
const config = {
|
||||
"info": {
|
||||
"name": "EditRoles",
|
||||
"author": "DevilBro",
|
||||
"version": "1.0.9",
|
||||
"description": "Allows you to locally edit Roles"
|
||||
},
|
||||
"changeLog": {
|
||||
"fixed": {
|
||||
"Remove Icon": "Now works again"
|
||||
}
|
||||
}
|
||||
const changeLog = {
|
||||
|
||||
};
|
||||
|
||||
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
|
||||
getName () {return config.info.name;}
|
||||
getAuthor () {return config.info.author;}
|
||||
getVersion () {return config.info.version;}
|
||||
getDescription () {return `The Library Plugin needed for ${config.info.name} is missing. Open the Plugin Settings to download it. \n\n${config.info.description}`;}
|
||||
constructor (meta) {for (let key in meta) this[key] = meta[key];}
|
||||
getName () {return this.name;}
|
||||
getAuthor () {return this.author;}
|
||||
getVersion () {return this.version;}
|
||||
getDescription () {return `The Library Plugin needed for ${this.name} is missing. Open the Plugin Settings to download it. \n\n${this.description}`;}
|
||||
|
||||
downloadLibrary () {
|
||||
require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (e, r, b) => {
|
||||
@@ -44,7 +35,7 @@ module.exports = (_ => {
|
||||
if (!window.BDFDB_Global || !Array.isArray(window.BDFDB_Global.pluginQueue)) window.BDFDB_Global = Object.assign({}, window.BDFDB_Global, {pluginQueue: []});
|
||||
if (!window.BDFDB_Global.downloadModal) {
|
||||
window.BDFDB_Global.downloadModal = true;
|
||||
BdApi.showConfirmationModal("Library Missing", `The Library Plugin needed for ${config.info.name} is missing. Please click "Download Now" to install it.`, {
|
||||
BdApi.showConfirmationModal("Library Missing", `The Library Plugin needed for ${this.name} is missing. Please click "Download Now" to install it.`, {
|
||||
confirmText: "Download Now",
|
||||
cancelText: "Cancel",
|
||||
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
|
||||
@@ -54,13 +45,13 @@ module.exports = (_ => {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
|
||||
if (!window.BDFDB_Global.pluginQueue.includes(this.name)) window.BDFDB_Global.pluginQueue.push(this.name);
|
||||
}
|
||||
start () {this.load();}
|
||||
stop () {}
|
||||
getSettingsPanel () {
|
||||
let template = document.createElement("template");
|
||||
template.innerHTML = `<div style="color: var(--header-primary); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The Library Plugin needed for ${config.info.name} is missing.\nPlease click <a style="font-weight: 500;">Download Now</a> to install it.</div>`;
|
||||
template.innerHTML = `<div style="color: var(--header-primary); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The Library Plugin needed for ${this.name} is missing.\nPlease click <a style="font-weight: 500;">Download Now</a> to install it.</div>`;
|
||||
template.content.firstElementChild.querySelector("a").addEventListener("click", this.downloadLibrary);
|
||||
return template.content.firstElementChild;
|
||||
}
|
||||
@@ -71,18 +62,21 @@ module.exports = (_ => {
|
||||
onLoad () {
|
||||
this.patchedModules = {
|
||||
before: {
|
||||
RoleMention: "default",
|
||||
AutocompleteRoleResult: "render",
|
||||
MessageHeader: "default",
|
||||
ChannelMembers: "render",
|
||||
MemberListItem: "render",
|
||||
UserPopoutBodySection: "default",
|
||||
UserPopoutBody: "default"
|
||||
},
|
||||
after: {
|
||||
RichRoleMention: "RoleMention"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
onStart () {
|
||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.GuildStore, "getGuild", {after: e => {
|
||||
if (e.returnValue) e.returnValue = this.changeRolesInGuild(e.returnValue, true);
|
||||
}});
|
||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.PermissionRoleUtils, "getHighestRole", {after: e => {
|
||||
if (e.returnValue && changedRoles[e.returnValue.id]) {
|
||||
let data = changedRoles[e.returnValue.id];
|
||||
@@ -168,14 +162,15 @@ module.exports = (_ => {
|
||||
if (e.subType == "useUserRolesItems") {
|
||||
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "roles"});
|
||||
if (index > -1 && children[index].props && BDFDB.ArrayUtils.is(children[index].props.children)) for (let child of children[index].props.children) {
|
||||
if (child && child.props && typeof child.props.label == "function") {
|
||||
if (child && child.props && typeof child.props.label == "function" && changedRoles[child.props.id]) {
|
||||
let data = changedRoles[child.props.id];
|
||||
let renderLabel = child.props.label;
|
||||
child.props.label = (...args) => {
|
||||
child.props.label = BDFDB.TimeUtils.suppress((...args) => {
|
||||
let label = renderLabel(...args);
|
||||
let onContextMenu = typeof label.props.onContextMenu == "function" ? label.props.onContextMenu : (_ => {});
|
||||
label.props.onContextMenu = event => BDFDB.LibraryModules.ContextMenuUtils.openContextMenu(event, e => BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("DeveloperContextMenu"), Object.assign({}, e2, {id: child.props.id})));
|
||||
if (data.color && label.props.children[0] && label.props.children[0].props) label.props.children[0].props.color = BDFDB.ColorUtils.convert(data.color, "hex");
|
||||
if (data.name && label.props.children[1] && label.props.children[1].props && label.props.children[1].props.children) label.props.children[1].props.children = data.name;
|
||||
return label;
|
||||
};
|
||||
}, "Error in renderLabel of UserRolesItems", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,6 +218,30 @@ module.exports = (_ => {
|
||||
].flat(10).filter(n => n);
|
||||
}
|
||||
|
||||
processRichRoleMention (e) {
|
||||
if (e.instance.props.id && changedRoles[e.instance.props.id]) {
|
||||
e.returnvalue.props.color = changedRoles[e.instance.props.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.id].color, "int") : e.returnvalue.props.color;
|
||||
e.returnvalue.props.children[1] = changedRoles[e.instance.props.id].name || e.returnvalue.props.children[1];
|
||||
}
|
||||
}
|
||||
|
||||
processRoleMention (e) {
|
||||
if (e.instance.props.roleId && changedRoles[e.instance.props.roleId]) {
|
||||
e.instance.props.roleColor = changedRoles[e.instance.props.roleId].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.roleId].color, "int") : e.instance.props.roleColor;
|
||||
e.instance.props.children = [`@${changedRoles[e.instance.props.roleId].name || e.instance.props.children[1]}`];
|
||||
if (e.instance.props.content && e.instance.props.content[0]) e.instance.props.content[0].content = `@${changedRoles[e.instance.props.roleId].name || e.instance.props.children[1]}`;
|
||||
}
|
||||
}
|
||||
|
||||
processAutocompleteRoleResult (e) {
|
||||
if (e.instance.props.role && changedRoles[e.instance.props.role.id]) {
|
||||
e.instance.props.role = Object.assign({}, e.instance.props.role);
|
||||
e.instance.props.role.color = changedRoles[e.instance.props.role.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.role.id].color, "int") : e.instance.props.role.color;
|
||||
e.instance.props.role.colorString = changedRoles[e.instance.props.role.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.role.id].color, "hex") : e.instance.props.role.colorString;
|
||||
e.instance.props.role.name = changedRoles[e.instance.props.role.id].name || e.instance.props.role.name;
|
||||
}
|
||||
}
|
||||
|
||||
processChannelMembers (e) {
|
||||
e.instance.props.groups = [].concat(e.instance.props.groups);
|
||||
for (let i in e.instance.props.groups) if (e.instance.props.groups[i].type == "GROUP") {
|
||||
@@ -243,6 +262,10 @@ module.exports = (_ => {
|
||||
}
|
||||
}
|
||||
|
||||
processUserPopoutBodySection (e) {
|
||||
if (e.instance.props.guild) e.instance.props.guild = this.changeRolesInGuild(e.instance.props.guild);
|
||||
}
|
||||
|
||||
processUserPopoutBody (e) {
|
||||
if (e.instance.props.guild) e.instance.props.guild = this.changeRolesInGuild(e.instance.props.guild);
|
||||
}
|
||||
@@ -677,5 +700,5 @@ module.exports = (_ => {
|
||||
}
|
||||
}
|
||||
};
|
||||
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
|
||||
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
|
||||
})();
|
||||
Reference in New Issue
Block a user