2020-10-20 23:25:34 +02:00
/ * *
2021-04-23 12:01:44 +02:00
* @ name StaffTag
2021-03-05 13:26:41 +01:00
* @ author DevilBro
2020-10-20 23:25:34 +02:00
* @ authorId 278543574059057154
2021-07-30 08:44:34 +02:00
* @ version 1.4 . 8
2021-04-30 16:28:10 +02:00
* @ description Adds a Crown / Tag to Server Owners ( or Admins / Management )
2020-10-20 23:25:34 +02:00
* @ invite Jx3TjNS
* @ donate https : //www.paypal.me/MircoWittrien
* @ patreon https : //www.patreon.com/MircoWittrien
2021-03-09 15:10:55 +01:00
* @ website https : //mwittrien.github.io/
2021-04-23 12:01:44 +02:00
* @ source https : //github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/StaffTag/
* @ updateUrl https : //mwittrien.github.io/BetterDiscordAddons/Plugins/StaffTag/StaffTag.plugin.js
2020-10-20 23:25:34 +02:00
* /
2019-01-09 12:56:24 +01:00
2020-09-19 20:49:33 +02:00
module . exports = ( _ => {
2020-10-09 21:09:35 +02:00
const config = {
2020-09-19 20:49:33 +02:00
"info" : {
2021-04-23 12:01:44 +02:00
"name" : "StaffTag" ,
2020-09-19 20:49:33 +02:00
"author" : "DevilBro" ,
2021-07-30 08:44:34 +02:00
"version" : "1.4.8" ,
2021-04-30 16:28:10 +02:00
"description" : "Adds a Crown/Tag to Server Owners (or Admins/Management)"
2020-10-07 10:20:55 +02:00
} ,
"changeLog" : {
2021-07-29 22:02:31 +02:00
"improved" : {
"Thread Creators" : "Added a dark gray crown for Thread Creators (they no longe appear as Server Owners)" ,
"Server Owner/Group Owner" : "Split the settings for Server and Group Owners, you can now change/disable them separately"
2020-10-07 10:20:55 +02:00
}
2021-08-02 20:18:26 +02:00
} ,
"changeLog" : {
"fixed" : {
"Member List Position" : ""
}
2020-02-04 08:20:40 +01:00
}
2020-09-19 20:49:33 +02:00
} ;
2020-11-13 19:47:44 +01:00
2021-08-11 17:33:29 +02:00
return ( window . Lightcord && ! Node . prototype . isPrototypeOf ( window . Lightcord ) || window . LightCord && ! Node . prototype . isPrototypeOf ( window . LightCord ) ) ? class {
2021-06-15 13:42:02 +02:00
getName ( ) { return config . info . name ; }
getAuthor ( ) { return config . info . author ; }
getVersion ( ) { return config . info . version ; }
getDescription ( ) { return "Do not use LightCord!" ; }
load ( ) { BdApi . alert ( "Attention!" , "By using LightCord you are risking your Discord Account, due to using a 3rd Party Client. Switch to an official Discord Client (https://discord.com/) with the proper BD Injection (https://betterdiscord.app/)" ) ; }
start ( ) { }
stop ( ) { }
} : ! window . BDFDB _Global || ( ! window . BDFDB _Global . loaded && ! window . BDFDB _Global . started ) ? class {
2021-01-06 12:38:36 +01:00
getName ( ) { return config . info . name ; }
getAuthor ( ) { return config . info . author ; }
getVersion ( ) { return config . info . version ; }
2021-02-01 17:13:13 +01:00
getDescription ( ) { return ` The Library Plugin needed for ${ config . info . name } is missing. Open the Plugin Settings to download it. \n \n ${ config . info . description } ` ; }
downloadLibrary ( ) {
require ( "request" ) . get ( "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js" , ( e , r , b ) => {
2021-03-05 13:14:18 +01:00
if ( ! e && b && r . statusCode == 200 ) require ( "fs" ) . writeFile ( require ( "path" ) . join ( BdApi . Plugins . folder , "0BDFDB.plugin.js" ) , b , _ => BdApi . showToast ( "Finished downloading BDFDB Library" , { type : "success" } ) ) ;
2021-03-06 14:59:48 +01:00
else BdApi . alert ( "Error" , "Could not download BDFDB Library Plugin. Try again later or download it manually from GitHub: https://mwittrien.github.io/downloader/?library" ) ;
2021-02-01 17:13:13 +01:00
} ) ;
}
2020-09-19 20:49:33 +02:00
2021-01-06 12:38:36 +01:00
load ( ) {
2020-11-19 16:51:14 +01:00
if ( ! window . BDFDB _Global || ! Array . isArray ( window . BDFDB _Global . pluginQueue ) ) window . BDFDB _Global = Object . assign ( { } , window . BDFDB _Global , { pluginQueue : [ ] } ) ;
2020-09-19 20:49:33 +02:00
if ( ! window . BDFDB _Global . downloadModal ) {
window . BDFDB _Global . downloadModal = true ;
2021-01-14 16:14:44 +01:00
BdApi . showConfirmationModal ( "Library Missing" , ` The Library Plugin needed for ${ config . info . name } is missing. Please click "Download Now" to install it. ` , {
2020-09-19 20:49:33 +02:00
confirmText : "Download Now" ,
cancelText : "Cancel" ,
onCancel : _ => { delete window . BDFDB _Global . downloadModal ; } ,
2020-09-20 08:15:13 +02:00
onConfirm : _ => {
delete window . BDFDB _Global . downloadModal ;
2021-02-01 17:13:13 +01:00
this . downloadLibrary ( ) ;
2020-09-20 08:15:13 +02:00
}
2020-09-19 20:49:33 +02:00
} ) ;
}
if ( ! window . BDFDB _Global . pluginQueue . includes ( config . info . name ) ) window . BDFDB _Global . pluginQueue . push ( config . info . name ) ;
2020-10-09 21:09:35 +02:00
}
2021-01-06 12:38:36 +01:00
start ( ) { this . load ( ) ; }
stop ( ) { }
getSettingsPanel ( ) {
2020-11-28 23:12:09 +01:00
let template = document . createElement ( "template" ) ;
2021-01-14 16:14:44 +01:00
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. \n Please click <a style="font-weight: 500;">Download Now</a> to install it.</div> ` ;
2021-02-01 17:13:13 +01:00
template . content . firstElementChild . querySelector ( "a" ) . addEventListener ( "click" , this . downloadLibrary ) ;
2020-11-28 23:12:09 +01:00
return template . content . firstElementChild ;
}
2020-10-09 21:09:35 +02:00
} : ( ( [ Plugin , BDFDB ] ) => {
2020-09-19 20:49:33 +02:00
const userTypes = {
NONE : 0 ,
MANAGEMENT : 1 ,
ADMIN : 2 ,
2021-07-29 22:02:31 +02:00
THREAD _CREATOR : 3 ,
GROUP _OWNER : 4 ,
OWNER : 5
2020-09-19 20:49:33 +02:00
} ;
2021-04-23 12:01:44 +02:00
return class StaffTag extends Plugin {
2021-01-06 12:38:36 +01:00
onLoad ( ) {
2020-09-19 20:49:33 +02:00
this . patchedModules = {
after : {
MemberListItem : "render" ,
2020-10-07 10:20:55 +02:00
MessageUsername : "default" ,
2021-03-03 14:35:05 +01:00
VoiceUser : "render" ,
2020-09-19 20:49:33 +02:00
NameTag : "default" ,
2021-06-25 10:14:18 +02:00
UserPopoutInfo : "UserPopoutInfo"
2020-09-19 20:49:33 +02:00
}
} ;
this . defaults = {
2021-03-08 16:02:53 +01:00
general : {
2021-07-29 22:02:31 +02:00
useCrown : { value : true , description : "Use the Crown Icon instead of the Bot Tag Style" } ,
useRoleColor : { value : true , description : "Use the Role Color instead of the default Blurple" } ,
useBlackFont : { value : false , description : "Use black Font instead of darkening the Role Color on bright Colors" } ,
ignoreBots : { value : false , description : "Don't add the Owner/Admin/Management Tag for Bots" }
2021-03-08 16:02:53 +01:00
} ,
tagTypes : {
2021-07-29 22:02:31 +02:00
owners : { value : true , description : "Server Owner Tag" } ,
groupOwners : { value : true , description : "Group Owner Tag" } ,
threadCreators : { value : true , description : "Thread Creator Tag" } ,
admins : { value : true , description : "Admin Tag (Admin Permissions)" } ,
managementG : { value : true , description : "Management Tag (Server Management)" } ,
managementC : { value : true , description : "Management Tag (Channel Management)" } ,
managementR : { value : true , description : "Management Tag (Role Management)" } ,
managementU : { value : true , description : "Management Tag (User Management 'Kick/Ban')" } ,
managementM : { value : true , description : "Management Tag (Message Management)" }
2021-03-08 16:02:53 +01:00
} ,
tagPlaces : {
2021-07-29 22:02:31 +02:00
chat : { value : true , description : "Messages" } ,
memberList : { value : true , description : "Member List" } ,
voiceList : { value : true , description : "Voice User List" } ,
userPopout : { value : true , description : "User Popouts" } ,
userProfile : { value : true , description : "User Profile Modal" } ,
2020-09-19 20:49:33 +02:00
} ,
inputs : {
2021-07-29 22:02:31 +02:00
ownOwnerTagName : { value : "Owner" , description : "Server Owner Tags" } ,
ownGroupOwnerTagName : { value : "Group Owner" , description : "Group Owner Tags" } ,
ownThreadCreatorTagName : { value : "Creator" , description : "Thread Creator Tags" } ,
ownAdminTagName : { value : "Admin" , description : "Admin Tags" } ,
ownManagementTagName : { value : "Management" , description : "Management Tags" }
2020-09-19 20:49:33 +02:00
}
} ;
2020-02-04 08:20:40 +01:00
2020-09-19 20:49:33 +02:00
this . css = `
2021-04-23 12:01:44 +02:00
$ { BDFDB . dotCN . memberownericon + BDFDB . dotCN . _stafftagadminicon } {
2021-04-15 16:24:21 +02:00
color : # aaa9ad ;
2020-09-19 20:49:33 +02:00
}
2021-04-23 12:01:44 +02:00
$ { BDFDB . dotCN . memberownericon + BDFDB . dotCN . _stafftagmanagementicon } {
2021-04-15 16:24:21 +02:00
color : # 88540 b ;
2020-09-19 20:49:33 +02:00
}
2021-07-29 22:02:31 +02:00
$ { BDFDB . dotCN . memberownericon + BDFDB . dotCN . _stafftagthreadcreatoricon } {
color : var ( -- text - muted ) ;
}
2021-08-02 20:18:26 +02:00
$ { BDFDB . dotCN . memberownericon } {
2021-03-03 14:35:05 +01:00
top : 0 px ;
}
2021-08-02 20:18:26 +02:00
$ { BDFDB . dotCNS . message + BDFDB . dotCN . memberownericon } {
top : 2 px ;
2021-03-03 14:35:05 +01:00
}
2021-07-29 22:02:31 +02:00
$ { BDFDB . dotCNS . messagecompact + BDFDB . dotCN . memberownericon } {
top : 1 px ;
2021-05-14 13:04:07 +02:00
margin - left : 0 ;
margin - right : 4 px ;
}
2021-07-29 22:02:31 +02:00
$ { BDFDB . dotCNS . messagerepliedmessage + BDFDB . dotCN . memberownericon } ,
$ { BDFDB . dotCNS . messagethreadaccessory + BDFDB . dotCN . memberownericon } {
top : 0 px ;
2020-12-07 19:42:24 +01:00
margin - left : 0 ;
margin - right : 4 px ;
}
2020-09-19 20:49:33 +02:00
` ;
2020-02-04 08:20:40 +01:00
}
2020-09-19 20:49:33 +02:00
2021-01-06 12:38:36 +01:00
onStart ( ) {
2020-02-04 08:20:40 +01:00
this . forceUpdateAll ( ) ;
}
2020-09-19 20:49:33 +02:00
2021-01-06 12:38:36 +01:00
onStop ( ) {
2020-02-04 08:20:40 +01:00
this . forceUpdateAll ( ) ;
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
getSettingsPanel ( collapseStates = { } ) {
2021-03-08 16:02:53 +01:00
let settingsPanel ;
return settingsPanel = BDFDB . PluginUtils . createSettingsPanel ( this , {
2020-09-19 20:49:33 +02:00
collapseStates : collapseStates ,
2021-03-08 16:02:53 +01:00
children : _ => {
let settingsItems = [ ] ;
2020-09-19 20:49:33 +02:00
2021-03-08 16:02:53 +01:00
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . CollapseContainer , {
title : "Settings" ,
collapseStates : collapseStates ,
2021-03-13 10:45:12 +01:00
children : Object . keys ( this . defaults . general ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
2021-03-08 16:02:53 +01:00
type : "Switch" ,
plugin : this ,
key : key ,
keys : [ "general" , key ] ,
label : this . defaults . general [ key ] . description ,
value : this . settings . general [ key ]
} ) )
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . CollapseContainer , {
title : "Tag Settings" ,
collapseStates : collapseStates ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsPanelList , {
title : "Add Tags for:" ,
dividerBottom : true ,
2021-03-13 10:45:12 +01:00
children : Object . keys ( this . defaults . tagTypes ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
2021-03-08 16:02:53 +01:00
type : "Switch" ,
plugin : this ,
keys : [ "tagTypes" , key ] ,
label : this . defaults . tagTypes [ key ] . description ,
value : this . settings . tagTypes [ key ]
} ) )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsPanelList , {
title : "Add Tags in:" ,
2021-03-13 10:45:12 +01:00
children : Object . keys ( this . defaults . tagPlaces ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
2021-03-08 16:02:53 +01:00
type : "Switch" ,
plugin : this ,
keys : [ "tagPlaces" , key ] ,
label : this . defaults . tagPlaces [ key ] . description ,
value : this . settings . tagPlaces [ key ]
} ) )
} )
]
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . CollapseContainer , {
title : "Tag Text Settings" ,
collapseStates : collapseStates ,
2021-03-13 10:45:12 +01:00
children : Object . keys ( this . defaults . inputs ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
2021-03-08 16:02:53 +01:00
type : "TextInput" ,
plugin : this ,
keys : [ "inputs" , key ] ,
label : this . defaults . inputs [ key ] . description ,
basis : "50%" ,
2021-03-08 19:55:59 +01:00
value : this . settings . inputs [ key ]
2021-03-08 16:02:53 +01:00
} ) )
} ) ) ;
return settingsItems ;
}
} ) ;
2020-02-04 08:20:40 +01:00
}
2019-09-04 12:34:02 +02:00
2021-01-06 12:38:36 +01:00
onSettingsClosed ( ) {
2020-09-19 20:49:33 +02:00
if ( this . SettingsUpdated ) {
delete this . SettingsUpdated ;
this . forceUpdateAll ( ) ;
}
}
2021-03-08 16:02:53 +01:00
forceUpdateAll ( ) {
2020-09-19 20:49:33 +02:00
BDFDB . PatchUtils . forceAllUpdates ( this ) ;
BDFDB . MessageUtils . rerenderAll ( ) ;
2020-02-04 08:20:40 +01:00
}
2019-09-04 12:34:02 +02:00
2020-09-19 20:49:33 +02:00
processMemberListItem ( e ) {
let userType = this . getUserType ( e . instance . props . user , e . instance . props . channel && e . instance . props . channel . id ) ;
2021-03-08 16:02:53 +01:00
if ( userType && this . settings . tagPlaces . memberList ) {
2021-04-23 12:01:44 +02:00
this . injectStaffTag ( BDFDB . ObjectUtils . get ( e . returnvalue , "props.decorators.props.children" ) , e . instance . props . user , userType , 1 , {
2021-03-03 14:35:05 +01:00
channelId : e . instance . props . channel && e . instance . props . channel . id ,
2020-09-19 20:49:33 +02:00
tagClass : BDFDB . disCN . bottagmember
2020-04-09 09:29:38 +02:00
} ) ;
2020-02-27 11:53:07 +01:00
}
2020-02-04 08:20:40 +01:00
}
2019-01-26 22:45:19 +01:00
2020-10-07 10:20:55 +02:00
processMessageUsername ( e ) {
2021-06-11 21:57:11 +02:00
if ( ! e . instance . props . message || ! this . settings . tagPlaces . chat ) return ;
const author = e . instance . props . userOverride || e . instance . props . message . author ;
let userType = this . getUserType ( author , e . instance . props . message . channel _id ) ;
if ( userType ) this . injectStaffTag ( e . returnvalue . props . children , author , userType , e . instance . props . compact ? 0 : 2 , {
channelId : e . instance . props . message . channel _id ,
tagClass : e . instance . props . compact ? BDFDB . disCN . messagebottagcompact : BDFDB . disCN . messagebottagcozy ,
useRem : true
} ) ;
2020-02-04 08:20:40 +01:00
}
2019-01-26 22:45:19 +01:00
2021-03-03 14:35:05 +01:00
processVoiceUser ( e ) {
2021-03-08 16:02:53 +01:00
if ( e . instance . props . user && this . settings . tagPlaces . voiceList ) {
2021-03-03 14:35:05 +01:00
let userType = this . getUserType ( e . instance . props . user , e . instance . props . channel && e . instance . props . channel . id ) ;
if ( userType ) {
let content = BDFDB . ReactUtils . findChild ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . voicecontent ] ] } ) ;
2021-04-23 12:01:44 +02:00
if ( content ) this . injectStaffTag ( content . props . children , e . instance . props . user , userType , 3 , {
2021-03-03 14:35:05 +01:00
channelId : e . instance . props . channel && e . instance . props . channel . id ,
} ) ;
}
}
}
2020-09-19 20:49:33 +02:00
processNameTag ( e ) {
if ( e . instance . props . user && e . instance . props . className ) {
let userType = this . getUserType ( e . instance . props . user ) ;
if ( userType ) {
let inject = false , tagClass = "" ;
switch ( e . instance . props . className ) {
case BDFDB . disCN . userpopoutheadertagnonickname :
2021-03-08 16:02:53 +01:00
inject = this . settings . tagPlaces . userPopout ;
2021-05-28 13:40:11 +02:00
tagClass = BDFDB . disCNS . userpopoutheaderbottag + BDFDB . disCN . bottagnametag ;
2020-09-19 20:49:33 +02:00
break ;
case BDFDB . disCN . userprofilenametag :
2021-03-08 16:02:53 +01:00
inject = this . settings . tagPlaces . userProfile ;
2020-09-19 20:49:33 +02:00
tagClass = BDFDB . disCNS . userprofilebottag + BDFDB . disCN . bottagnametag ;
break ;
}
2021-04-23 12:01:44 +02:00
if ( inject ) this . injectStaffTag ( e . returnvalue . props . children , e . instance . props . user , userType , 2 , {
2020-09-19 20:49:33 +02:00
tagClass : tagClass ,
useRem : e . instance . props . useRemSizes ,
inverted : e . instance . props . invertBotTagColor
} ) ;
}
2020-02-04 08:20:40 +01:00
}
}
2021-05-21 17:51:26 +02:00
2021-06-03 16:27:44 +02:00
processUserPopoutInfo ( e ) {
2021-03-08 16:02:53 +01:00
if ( e . instance . props . user && this . settings . tagPlaces . userPopout ) {
2020-09-19 20:49:33 +02:00
let userType = this . getUserType ( e . instance . props . user , e . instance . props . channel && e . instance . props . channel . id ) ;
if ( userType ) {
2021-05-27 16:39:47 +02:00
let [ children , index ] = BDFDB . ReactUtils . findParent ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . userpopoutheadernickname ] ] } ) ;
if ( index > - 1 ) {
if ( ! BDFDB . ArrayUtils . is ( children [ index ] . props . children ) ) children [ index ] . props . children = [ children [ index ] . props . children ] . flat ( 10 ) ;
this . injectStaffTag ( children [ index ] . props . children , e . instance . props . user , userType , 2 , {
2021-05-28 13:40:11 +02:00
tagClass : BDFDB . disCNS . userpopoutheaderbottag + BDFDB . disCN . bottagnametag ,
2021-05-27 16:39:47 +02:00
inverted : typeof e . instance . getMode == "function" && e . instance . getMode ( ) !== "Normal"
} ) ;
}
2020-09-19 20:49:33 +02:00
}
2020-08-29 19:52:21 +02:00
}
2020-02-04 08:20:40 +01:00
}
2020-09-19 20:49:33 +02:00
2021-04-23 12:01:44 +02:00
injectStaffTag ( children , user , userType , insertIndex , config = { } ) {
2020-09-19 20:49:33 +02:00
if ( ! BDFDB . ArrayUtils . is ( children ) || ! user ) return ;
2021-03-08 16:02:53 +01:00
let [ _ , index ] = BDFDB . ReactUtils . findParent ( children , { props : [ [ "text" , [ BDFDB . LanguageUtils . LanguageStrings . GROUP _OWNER , BDFDB . LanguageUtils . LanguageStrings . GUILD _OWNER ] ] ] } ) ;
if ( index > - 1 ) children [ index ] = null ;
2021-01-27 15:27:42 +01:00
let channel = BDFDB . LibraryModules . ChannelStore . getChannel ( config . channelId || BDFDB . LibraryModules . LastChannelStore . getChannelId ( ) ) ;
2021-03-08 16:02:53 +01:00
let member = channel && this . settings . general . useRoleColor ? ( BDFDB . LibraryModules . MemberStore . getMember ( channel . guild _id , user . id ) || { } ) : { } ;
2020-09-19 20:49:33 +02:00
let tag = null ;
2021-03-08 16:02:53 +01:00
if ( this . settings . general . useCrown ) {
2020-09-19 20:49:33 +02:00
let label , className ;
switch ( userType ) {
case userTypes . OWNER :
2021-07-29 22:02:31 +02:00
label = BDFDB . LanguageUtils . LanguageStrings . GUILD _OWNER ;
2021-04-23 12:01:44 +02:00
className = BDFDB . disCN . _stafftagownericon ;
2020-09-19 20:49:33 +02:00
break ;
2021-07-29 22:02:31 +02:00
case userTypes . GROUP _OWNER :
label = BDFDB . LanguageUtils . LanguageStrings . GROUP _OWNER ;
className = BDFDB . disCN . _stafftaggroupownericon ;
break ;
case userTypes . THREAD _CREATOR :
label = this . labels . creator . replace ( "{{var0}}" , BDFDB . LanguageUtils . LanguageStrings . THREAD ) ;
className = BDFDB . disCN . _stafftagthreadcreatoricon ;
break ;
2020-09-19 20:49:33 +02:00
case userTypes . ADMIN :
label = BDFDB . LanguageUtils . LanguageStrings . ADMINISTRATOR ;
2021-04-23 12:01:44 +02:00
className = BDFDB . disCN . _stafftagadminicon ;
2020-09-19 20:49:33 +02:00
break ;
case userTypes . MANAGEMENT :
2021-03-08 16:02:53 +01:00
label = ` ${ this . labels . management } ( ${ this . getManagementLabel ( user ) } ) ` ;
2021-04-23 12:01:44 +02:00
className = BDFDB . disCN . _stafftagmanagementicon ;
2020-09-19 20:49:33 +02:00
break ;
}
tag = BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TooltipContainer , {
text : label ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SvgIcon , {
className : BDFDB . DOMUtils . formatClassName ( BDFDB . disCN . memberownericon , className ) ,
name : BDFDB . LibraryComponents . SvgIcon . Names . CROWN ,
"aria-label" : label
} )
} ) ;
}
else {
let input , label ;
switch ( userType ) {
case userTypes . OWNER :
2021-03-08 16:02:53 +01:00
input = "ownOwnerTagName" ;
2020-09-19 20:49:33 +02:00
break ;
2021-07-29 22:02:31 +02:00
case userTypes . GROUP _OWNER :
input = "ownGroupOwnerTagName" ;
break ;
case userTypes . THREAD _CREATOR :
input = "ownThreadCreatorTagName" ;
break ;
2020-09-19 20:49:33 +02:00
case userTypes . ADMIN :
input = "ownAdminTagName" ;
break ;
case userTypes . MANAGEMENT :
input = "ownManagementTagName" ;
2021-03-08 16:02:53 +01:00
label = this . getManagementLabel ( user ) ;
2020-09-19 20:49:33 +02:00
break ;
}
let tagColor = BDFDB . ColorUtils . convert ( member . colorString , "RGBA" ) ;
let isBright = BDFDB . ColorUtils . isBright ( tagColor ) ;
2021-03-08 16:02:53 +01:00
tagColor = isBright ? ( this . settings . general . useBlackFont ? tagColor : BDFDB . ColorUtils . change ( tagColor , - 0.3 ) ) : tagColor ;
2020-09-19 20:49:33 +02:00
tag = BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . BotTag , {
className : config . tagClass ,
useRemSizes : config . useRem ,
invertColor : config . inverted ,
style : {
2021-03-08 16:02:53 +01:00
backgroundColor : config . inverted ? ( isBright && this . settings . general . useBlackFont ? "black" : null ) : tagColor ,
color : ! config . inverted ? ( isBright && this . settings . general . useBlackFont ? "black" : null ) : tagColor
2020-09-19 20:49:33 +02:00
} ,
2021-03-08 16:02:53 +01:00
tag : this . settings . inputs [ input ]
2020-09-19 20:49:33 +02:00
} ) ;
if ( label ) tag = BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TooltipContainer , {
text : label ,
children : tag
} ) ;
}
children . splice ( insertIndex , 0 , tag ) ;
2020-02-04 08:20:40 +01:00
}
2020-05-25 17:16:19 +02:00
2021-03-08 16:02:53 +01:00
getManagementLabel ( user ) {
return [
this . settings . tagTypes . managementG && BDFDB . UserUtils . can ( "MANAGE_GUILD" , user . id ) && BDFDB . LanguageUtils . LibraryStrings . server ,
this . settings . tagTypes . managementC && BDFDB . UserUtils . can ( "MANAGE_CHANNELS" , user . id ) && BDFDB . LanguageUtils . LanguageStrings . CHANNELS ,
this . settings . tagTypes . managementR && BDFDB . UserUtils . can ( "MANAGE_ROLES" , user . id ) && BDFDB . LanguageUtils . LanguageStrings . ROLES ,
this . settings . tagTypes . managementU && ( BDFDB . UserUtils . can ( "BAN_MEMBERS" , user . id ) || BDFDB . UserUtils . can ( "KICK_MEMBERS" , user . id ) ) && BDFDB . LanguageUtils . LanguageStrings . MEMBERS ,
this . settings . tagTypes . managementM && BDFDB . UserUtils . can ( "MANAGE_MESSAGES" , user . id ) && BDFDB . LanguageUtils . LanguageStrings . MESSAGES
] . filter ( n => n ) . join ( ", " ) ;
}
2020-09-19 20:49:33 +02:00
getUserType ( user , channelId ) {
2021-03-08 16:02:53 +01:00
if ( ! user || this . settings . general . ignoreBots && user . bot ) return userTypes . NONE ;
2021-07-29 22:02:31 +02:00
const channel = BDFDB . LibraryModules . ChannelStore . getChannel ( channelId || BDFDB . LibraryModules . LastChannelStore . getChannelId ( ) ) ;
2020-09-19 20:49:33 +02:00
if ( ! channel ) return userTypes . NONE ;
2021-07-29 22:02:31 +02:00
const guild = BDFDB . LibraryModules . GuildStore . getGuild ( channel . guild _id ) ;
2021-07-30 08:44:34 +02:00
if ( this . settings . tagTypes . owners && guild && guild . ownerId == user . id ) return userTypes . OWNER ;
else if ( this . settings . tagTypes . groupOwners && channel . ownerId == user . id && channel . isGroupDM ( ) ) return userTypes . GROUP _OWNER ;
else if ( this . settings . tagTypes . threadCreators && channel . ownerId == user . id && BDFDB . ChannelUtils . isThread ( channel ) ) return userTypes . THREAD _CREATOR ;
2021-03-08 16:02:53 +01:00
else if ( this . settings . tagTypes . admins && BDFDB . UserUtils . can ( "ADMINISTRATOR" , user . id ) ) return userTypes . ADMIN ;
else if ( this . settings . tagTypes . managementG && BDFDB . UserUtils . can ( "MANAGE_GUILD" , user . id ) || this . settings . tagTypes . managementC && BDFDB . UserUtils . can ( "MANAGE_CHANNELS" , user . id ) || this . settings . tagTypes . managementR && BDFDB . UserUtils . can ( "MANAGE_ROLES" , user . id ) || this . settings . tagTypes . managementU && ( BDFDB . UserUtils . can ( "BAN_MEMBERS" , user . id ) || BDFDB . UserUtils . can ( "KICK_MEMBERS" , user . id ) ) || this . settings . tagTypes . managementM && BDFDB . UserUtils . can ( "MANAGE_MESSAGES" , user . id ) ) return userTypes . MANAGEMENT ;
2020-09-19 20:49:33 +02:00
return userTypes . NONE ;
2020-08-31 23:32:22 +02:00
}
2020-07-26 16:39:51 +02:00
2021-01-06 12:38:36 +01:00
setLabelsByLanguage ( ) {
2020-09-19 20:49:33 +02:00
switch ( BDFDB . LanguageUtils . getLanguage ( ) . id ) {
2020-12-21 19:56:36 +01:00
case "bg" : // Bulgarian
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Управление" ,
creator : "{{var0}} създател"
} ;
case "cs" : // Czech
return {
management : "Řízení" ,
creator : "{{var0}} autor"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "da" : // Danish
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Ledelse" ,
creator : "{{var0}} skaber"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "de" : // German
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Verwaltung" ,
creator : "{{var0}}ersteller"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "el" : // Greek
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Διαχείριση" ,
creator : "{{var0}} δημιουργός"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "es" : // Spanish
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Administración" ,
creator : "{{var0}} creador"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "fi" : // Finnish
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Johto" ,
creator : "{{var0}} luoja"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "fr" : // French
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "La gestion" ,
creator : "{{var0}}créateur"
} ;
case "hi" : // Hindi
return {
management : "प्रबंध" ,
creator : "{{var0}}निर्माता"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "hr" : // Croatian
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Upravljanje" ,
creator : "{{var0}} kreator"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "hu" : // Hungarian
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Menedzsment" ,
creator : "{{var0}} alkotója"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "it" : // Italian
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Gestione" ,
creator : "{{var0}}creatore"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "ja" : // Japanese
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "管理" ,
creator : "{{var0}}作成者"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "ko" : // Korean
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "조치" ,
creator : "{{var0}}창조자"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "lt" : // Lithuanian
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Valdymas" ,
creator : "{{var0}} kūrėjas"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "nl" : // Dutch
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Beheer" ,
creator : "{{var0}}maker"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "no" : // Norwegian
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Ledelse" ,
creator : "{{var0}} skaperen"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "pl" : // Polish
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Zarządzanie" ,
creator : "{{var0}}twórca"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "pt-BR" : // Portuguese (Brazil)
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Gestão" ,
creator : "{{var0}} criador"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "ro" : // Romanian
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Administrare" ,
creator : "{{var0}} creator"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "ru" : // Russian
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Управление" ,
creator : "{{var0}} создатель"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "sv" : // Swedish
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "Förvaltning" ,
creator : "{{var0}} skapare"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "th" : // Thai
2020-09-19 20:49:33 +02:00
return {
2021-07-29 22:02:31 +02:00
management : "การจัดการ" ,
creator : "{{var0}}ผู้สร้าง"
2020-12-21 19:56:36 +01:00
} ;
case "tr" : // Turkish
return {
2021-07-29 22:02:31 +02:00
management : "Yönetim" ,
creator : "{{var0}}yaratı cı "
2020-12-21 19:56:36 +01:00
} ;
case "uk" : // Ukrainian
return {
2021-07-29 22:02:31 +02:00
management : "Управління" ,
creator : "{{var0}} творець"
2020-12-21 19:56:36 +01:00
} ;
case "vi" : // Vietnamese
return {
2021-07-29 22:02:31 +02:00
management : "Sự quản lý" ,
creator : "Người tạo {{var0}}"
2020-12-21 19:56:36 +01:00
} ;
2021-01-15 17:54:22 +01:00
case "zh-CN" : // Chinese (China)
2020-12-21 19:56:36 +01:00
return {
2021-07-29 22:02:31 +02:00
management : "管理" ,
creator : "{{var0}}创建者"
2020-12-21 19:56:36 +01:00
} ;
2021-01-15 17:54:22 +01:00
case "zh-TW" : // Chinese (Taiwan)
2020-12-21 19:56:36 +01:00
return {
2021-07-29 22:02:31 +02:00
management : "管理" ,
creator : "{{var0}}創建者"
2020-12-21 19:56:36 +01:00
} ;
default : // English
return {
2021-07-29 22:02:31 +02:00
management : "Management" ,
creator : "{{var0}} Creator"
2020-09-19 20:49:33 +02:00
} ;
}
}
} ;
2020-10-09 21:09:35 +02:00
} ) ( window . BDFDB _Global . PluginUtils . buildPlugin ( config ) ) ;
2021-03-08 19:55:59 +01:00
} ) ( ) ;