Update OwnerTag.plugin.js
This commit is contained in:
parent
8841a060e4
commit
986c1aa14a
|
@ -3,7 +3,7 @@
|
|||
class OwnerTag {
|
||||
getName () {return "OwnerTag";}
|
||||
|
||||
getVersion () {return "1.0.8";}
|
||||
getVersion () {return "1.0.9";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -11,7 +11,7 @@ class OwnerTag {
|
|||
|
||||
initConstructor () {
|
||||
this.changelog = {
|
||||
"added":[["Added OwnerIcon Option","You can now switch from the OwnerTag to the native Crown OwnerIcon"]]
|
||||
"added":[["Admin Tags","You can now enable the plugin to also add tags for users with administration rights, you can also set a unique tagname for such people"]]
|
||||
};
|
||||
|
||||
this.patchModules = {
|
||||
|
@ -28,10 +28,12 @@ class OwnerTag {
|
|||
addInUserProfil: {value:true, inner:true, description:"User Profile Modal"},
|
||||
useRoleColor: {value:true, inner:false, description:"Use the Rolecolor instead of the default blue."},
|
||||
useBlackFont: {value:false, inner:false, description:"Instead of darkening the Rolecolor on bright colors use black font."},
|
||||
useCrown: {value:false, inner:false, description:"Use the Crown OwnerIcon instead of the OwnerTag."}
|
||||
useCrown: {value:false, inner:false, description:"Use the Crown OwnerIcon instead of the OwnerTag."},
|
||||
addForAdmins: {value:false, inner:false, description:"Also add the Tag for any user with Admin rights."}
|
||||
},
|
||||
inputs: {
|
||||
ownTagName: {value:"Owner", description:"Owner Tag Text"}
|
||||
ownTagName: {value:"Owner", description:"Owner Tag Text for Owners"},
|
||||
ownAdminTagName: {value:"Admin", description:"Owner Tag Text for Admins"}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -42,7 +44,7 @@ class OwnerTag {
|
|||
var inputs = BDFDB.getAllData(this, "inputs");
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="DevilBro-settings-inner">`;
|
||||
for (let key in inputs) {
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 30%; line-height: 38px;">${this.defaults.inputs[key].description}</h3><div class="${BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex + BDFDB.disCN.directioncolumn}" style="flex: 1 1 auto;"><input type="text" option="${key}" value="${inputs[key]}" placeholder="${this.defaults.inputs[key].value}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16}"></div></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 50%;">${this.defaults.inputs[key].description}</h3><div class="${BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex + BDFDB.disCN.directioncolumn}" style="flex: 1 1 auto;"><input type="text" option="${key}" value="${inputs[key]}" placeholder="${this.defaults.inputs[key].value}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16}"></div></div>`;
|
||||
}
|
||||
for (let key in settings) {
|
||||
if (!this.defaults.settings[key].inner) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
|
||||
|
@ -90,7 +92,8 @@ class OwnerTag {
|
|||
|
||||
this.MemberUtils = BDFDB.WebModules.findByProperties("getMembers", "getMember");
|
||||
this.GuildUtils = BDFDB.WebModules.findByProperties("getGuilds","getGuild");
|
||||
this.LastGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels","getChannel");
|
||||
this.LastChannelStore = BDFDB.WebModules.findByProperties("getLastSelectedChannelId");
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
|
@ -122,13 +125,13 @@ class OwnerTag {
|
|||
let container = null;
|
||||
if (!instance.props || !wrapper.classList) return;
|
||||
else if (BDFDB.containsClass(wrapper, BDFDB.disCN.membernametag) && BDFDB.getData("addInMemberList", this, "settings")) {
|
||||
this.addOwnerTag(instance.props.user, wrapper, "list", BDFDB.disCN.bottagnametag + (instance.props.botClass ? (" " + instance.props.botClass) : ""), container);
|
||||
this.addOwnerTag(instance.props.user, null, wrapper, "list", BDFDB.disCN.bottagnametag + (instance.props.botClass ? (" " + instance.props.botClass) : ""), container);
|
||||
}
|
||||
else if ((container = BDFDB.getParentEle(BDFDB.dotCN.userpopout, wrapper)) != null && BDFDB.getData("addInUserPopout", this, "settings")) {
|
||||
this.addOwnerTag(instance.props.user, wrapper, "popout", BDFDB.disCN.bottagnametag + (instance.props.botClass ? (" " + instance.props.botClass) : ""), container);
|
||||
this.addOwnerTag(instance.props.user, null, wrapper, "popout", BDFDB.disCN.bottagnametag + (instance.props.botClass ? (" " + instance.props.botClass) : ""), container);
|
||||
}
|
||||
else if ((container = BDFDB.getParentEle(BDFDB.dotCN.userprofile, wrapper)) != null && BDFDB.getData("addInUserProfil", this, "settings")) {
|
||||
this.addOwnerTag(instance.props.user, wrapper, "profile", BDFDB.disCN.bottagnametag + (instance.props.botClass ? (" " + instance.props.botClass) : ""), container);
|
||||
this.addOwnerTag(instance.props.user, null, wrapper, "profile", BDFDB.disCN.bottagnametag + (instance.props.botClass ? (" " + instance.props.botClass) : ""), container);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +141,7 @@ class OwnerTag {
|
|||
let username = wrapper.querySelector(BDFDB.dotCN.messageusername);
|
||||
if (username) {
|
||||
let messagegroup = BDFDB.getParentEle(BDFDB.dotCN.messagegroup, wrapper);
|
||||
this.addOwnerTag(message.author, username.parentElement, "chat", BDFDB.disCN.bottagmessage + " " + (BDFDB.containsClass(messagegroup, BDFDB.disCN.messagegroupcozy) ? BDFDB.disCN.bottagmessagecozy : BDFDB.disCN.bottagmessagecompact), null);
|
||||
this.addOwnerTag(message.author, message.channel_id, username.parentElement, "chat", BDFDB.disCN.bottagmessage + " " + (BDFDB.containsClass(messagegroup, BDFDB.disCN.messagegroupcozy) ? BDFDB.disCN.bottagmessagecozy : BDFDB.disCN.bottagmessagecompact), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,16 +154,19 @@ class OwnerTag {
|
|||
}
|
||||
}
|
||||
|
||||
addOwnerTag (info, wrapper, type, selector = "", container) {
|
||||
addOwnerTag (info, channelid, wrapper, type, selector = "", container) {
|
||||
if (!info || !wrapper || !wrapper.parentElement) return;
|
||||
BDFDB.removeEles(wrapper.querySelectorAll(".owner-tag, .owner-tag-crown"));
|
||||
let guild = this.GuildUtils.getGuild(this.LastGuildStore.getGuildId());
|
||||
if (!guild || guild.ownerId != info.id) return;
|
||||
let channel = this.ChannelUtils.getChannel(channelid || this.LastChannelStore.getChannelId());
|
||||
if (!channel) return;
|
||||
let guild = this.GuildUtils.getGuild(channel.guild_id);
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let member = settings.useRoleColor ? (this.MemberUtils.getMember(this.LastGuildStore.getGuildId(), info.id) || {}) : {};
|
||||
let isowner = channel.ownerId == info.id || guild && guild.ownerId == info.id;
|
||||
if (!(isowner || (settings.addForAdmins && BDFDB.isUserAllowedTo("ADMINISTRATOR", info.id)))) return;
|
||||
let member = settings.useRoleColor ? (this.MemberUtils.getMember(channel.guild_id, info.id) || {}) : {};
|
||||
let EditUsersData = BDFDB.isPluginEnabled("EditUsers") ? bdplugins.EditUsers.plugin.getUserData(info.id, wrapper) : {};
|
||||
if (!settings.useCrown) {
|
||||
let tag = BDFDB.htmlToElement(`<span class="owner-tag owner-${type}-tag ${(settings.useRoleColor ? "owner-tag-rolecolor " : "") + BDFDB.disCN.bottag + (selector ? (" " + selector) : "")}" style="order: 10 !important;">${BDFDB.getData("ownTagName", this, "inputs") || "Owner"}</span>`);
|
||||
let tag = BDFDB.htmlToElement(`<span class="owner-tag owner-${type}-tag ${(settings.useRoleColor ? "owner-tag-rolecolor " : "") + BDFDB.disCN.bottag + (selector ? (" " + selector) : "")}" style="order: 10 !important;">${BDFDB.getData(isowner ? "ownTagName" : "ownAdminTagName", this, "inputs")}</span>`);
|
||||
let invert = false;
|
||||
if (container && container.firstElementChild && !BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userpopoutheadernormal, BDFDB.disCN.userprofiletopsectionnormal), false) invert = true;
|
||||
BDFDB.addClass(tag, invert ? BDFDB.disCN.bottaginvert : BDFDB.disCN.bottagregular);
|
||||
|
@ -174,7 +180,7 @@ class OwnerTag {
|
|||
else if (!wrapper.querySelector(BDFDB.dotCN.ownericon)) {
|
||||
let crown = BDFDB.htmlToElement(`<svg name="Crown" class="owner-tag-crown ${BDFDB.disCNS.ownericon + BDFDB.disCN.memberownericon}" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path fill="#faa61a" fill-rule="nonzero" d="M2,11 L0,0 L5.5,7 L9,0 L12.5,7 L18,0 L16,11 L2,11 L2,11 Z M16,14 C16,14.5522847 15.5522847,15 15,15 L3,15 C2.44771525,15 2,14.5522847 2,14 L2,13 L16,13 L16,14 Z" transform="translate(3 4)"></path><rect width="24" height="24"></rect></g></svg>`);
|
||||
crown.addEventListener("mouseenter", () => {
|
||||
BDFDB.createTooltip(BDFDB.LanguageStrings.GUILD_OWNER, crown, {type: "top"});
|
||||
BDFDB.createTooltip(isowner ? (channel.type == 3 ? BDFDB.LanguageStrings.GROUP_OWNER : BDFDB.LanguageStrings.GUILD_OWNER) : BDFDB.LanguageStrings.ADMINISTRATOR, crown, {type: "top"});
|
||||
});
|
||||
wrapper.insertBefore(crown, wrapper.querySelector(".TRE-tag,svg[name=MobileDevice]"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue