2020-10-20 23:25:34 +02:00
/ * *
* @ name ShowHiddenChannels
2021-03-05 13:26:41 +01:00
* @ author DevilBro
2020-10-20 23:25:34 +02:00
* @ authorId 278543574059057154
2021-06-15 11:48:34 +02:00
* @ version 3.0 . 0
2021-03-05 13:26:41 +01:00
* @ description Displays all hidden Channels , which can 't be accessed due to Role Restrictions, this won' t allow you to read them ( impossible )
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/
* @ source https : //github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ShowHiddenChannels/
2021-03-10 09:17:37 +01:00
* @ updateUrl https : //mwittrien.github.io/BetterDiscordAddons/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js
2020-10-20 23:25:34 +02:00
* /
2018-10-11 10:21:26 +02: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" : {
"name" : "ShowHiddenChannels" ,
"author" : "DevilBro" ,
2021-06-15 11:48:34 +02:00
"version" : "3.0.0" ,
2021-03-05 11:21:21 +01:00
"description" : "Displays all hidden Channels, which can't be accessed due to Role Restrictions, this won't allow you to read them (impossible)"
2021-06-15 11:48:34 +02:00
} ,
"changeLog" : {
"improved" : {
"Sort Order" : "Added a third option, which allows you to sort hidden channels in their native category BUT at the bottom of the category's own list"
}
2020-09-19 20:49:33 +02:00
}
2020-04-09 21:00:35 +02:00
} ;
2020-11-18 17:51:23 +01:00
2020-10-09 21:09:35 +02:00
return ! 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-06-09 21:51:14 +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 ] ) => {
2021-01-13 19:28:23 +01:00
var blackList = [ ] , collapseList = [ ] , hiddenCategory , lastGuildId , overrideTypes = [ ] ;
2020-10-29 16:48:14 +01:00
var hiddenChannelCache = { } ;
2021-03-01 13:32:54 +01:00
var accessModal ;
2020-10-29 16:48:14 +01:00
2021-05-07 12:09:11 +02:00
const channelGroupMap = {
2021-04-01 18:39:59 +02:00
GUILD _TEXT : "SELECTABLE" ,
2021-05-07 12:09:11 +02:00
GUILD _VOICE : "VOCAL" ,
GUILD _ANNOUNCEMENT : "SELECTABLE" ,
GUILD _STORE : "SELECTABLE" ,
2021-04-01 18:39:59 +02:00
} ;
2019-09-04 12:34:02 +02:00
2020-10-29 16:48:14 +01:00
const typeNameMap = {
2021-01-25 18:23:02 +01:00
GUILD _TEXT : "TEXT_CHANNEL" ,
2020-10-29 16:48:14 +01:00
GUILD _VOICE : "VOICE_CHANNEL" ,
GUILD _ANNOUNCEMENT : "NEWS_CHANNEL" ,
GUILD _STORE : "STORE_CHANNEL" ,
2021-05-07 12:09:11 +02:00
GUILD _CATEGORY : "CATEGORY" ,
GUILD _STAGE _VOICE : "STAGE_CHANNEL"
2020-10-29 16:48:14 +01:00
} ;
2021-06-15 11:48:34 +02:00
const sortOrders = {
EXTRA : { value : "extra" , label : "Extra Category 'Hidden'" } ,
2021-06-15 13:05:28 +02:00
NATIVE : { value : "native" , label : "Native Category in correct Order" } ,
2021-06-15 11:48:34 +02:00
BOTTOM : { value : "bottom" , label : "Native Category at the bottom" }
} ;
2021-02-04 19:46:29 +01:00
const UserRowComponent = class UserRow extends BdApi . React . Component {
2021-01-20 16:00:29 +01:00
componentDidMount ( ) {
2020-10-29 16:48:14 +01:00
if ( this . props . user . fetchable ) {
this . props . user . fetchable = false ;
BDFDB . LibraryModules . UserFetchUtils . getUser ( this . props . user . id ) . then ( fetchedUser => {
this . props . user = Object . assign ( { } , fetchedUser , BDFDB . LibraryModules . MemberStore . getMember ( this . props . guildId , this . props . user . id ) || { } ) ;
BDFDB . ReactUtils . forceUpdate ( this ) ;
2020-09-19 20:49:33 +02:00
} ) ;
2020-03-13 12:28:36 +01:00
}
2020-10-29 16:48:14 +01:00
}
2021-01-20 16:00:29 +01:00
render ( ) {
2020-10-29 16:48:14 +01:00
return BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ListRow , {
2021-01-25 18:23:02 +01:00
prefix : BDFDB . ReactUtils . createElement ( "div" , {
2020-10-29 16:48:14 +01:00
className : BDFDB . disCN . listavatar ,
2021-01-25 18:23:02 +01:00
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . AvatarComponents . default , {
src : BDFDB . UserUtils . getAvatar ( this . props . user . id ) ,
status : BDFDB . UserUtils . getStatus ( this . props . user . id ) ,
2021-03-01 13:32:54 +01:00
size : BDFDB . LibraryComponents . AvatarComponents . Sizes . SIZE _40 ,
onClick : _ => {
if ( accessModal ) accessModal . props . onClose ( ) ;
2021-06-08 23:14:34 +02:00
BDFDB . LibraryModules . UserProfileModalUtils . openUserProfileModal ( {
userId : this . props . user . id ,
guildId : this . props . guildId
} ) ;
2021-03-01 13:32:54 +01:00
}
2021-01-25 18:23:02 +01:00
} )
2020-10-29 16:48:14 +01:00
} ) ,
2021-06-09 20:59:58 +02:00
labelClassName : BDFDB . disCN . nametag ,
2020-10-29 16:48:14 +01:00
label : [
BDFDB . ReactUtils . createElement ( "span" , {
className : BDFDB . disCN . username ,
children : this . props . user . username ,
style : { color : this . props . user . colorString }
2020-09-19 20:49:33 +02:00
} ) ,
2020-10-29 16:48:14 +01:00
! this . props . user . discriminator ? null : BDFDB . ReactUtils . createElement ( "span" , {
className : BDFDB . disCN . listdiscriminator ,
children : ` # ${ this . props . user . discriminator } `
2021-05-06 20:04:14 +02:00
} ) ,
this . props . user . bot && BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . BotTag , {
style : { marginLeft : 6 }
2020-09-19 20:49:33 +02:00
} )
2020-10-29 16:48:14 +01:00
]
} ) ;
}
} ;
2021-02-04 19:46:29 +01:00
const RoleRowComponent = class RoleRow extends BdApi . React . Component {
2021-01-20 16:00:29 +01:00
render ( ) {
2020-10-29 16:48:14 +01:00
return BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ListRow , {
prefix : BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCNS . avataricon + BDFDB . disCNS . listavatar + BDFDB . disCNS . avatariconsizemedium + BDFDB . disCN . avatariconinactive ,
style : {
boxSizing : "border-box" ,
padding : 10
} ,
children : BDFDB . ReactUtils . createElement ( "div" , {
style : {
borderRadius : "50%" ,
height : "100%" ,
width : "100%" ,
backgroundColor : BDFDB . ColorUtils . convert ( this . props . role . colorString || BDFDB . DiscordConstants . Colors . PRIMARY _DARK _300 , "RGB" )
}
} )
} ) ,
labelClassName : this . props . role . overwritten && BDFDB . disCN . strikethrough ,
label : BDFDB . ReactUtils . createElement ( "span" , {
children : this . props . role . name ,
style : { color : this . props . role . colorString }
} )
} ) ;
}
} ;
2020-09-19 20:49:33 +02:00
2020-10-09 21:09:35 +02:00
return class ShowHiddenChannels extends Plugin {
2021-01-06 12:38:36 +01:00
onLoad ( ) {
2020-09-19 20:49:33 +02:00
overrideTypes = Object . keys ( BDFDB . DiscordConstants . PermissionOverrideType ) ;
this . defaults = {
2021-06-15 11:48:34 +02:00
sortOrder : {
hidden : {
value : sortOrders [ Object . keys ( sortOrders ) [ 0 ] ] . value ,
description : "Sorts hidden Channels in" ,
options : Object . keys ( sortOrders ) . map ( n => sortOrders [ n ] )
}
} ,
2021-05-07 12:09:11 +02:00
general : {
2021-06-15 11:48:34 +02:00
alwaysCollapse : { value : false , description : "Always collapse 'Hidden' Category after switching Servers" } ,
showVoiceUsers : { value : true , description : "Show connected Users in hidden Voice Channels" } ,
showForNormal : { value : true , description : "Add Access-Overview ContextMenu Entry for non-hidden Channels" }
2021-05-07 12:09:11 +02:00
} ,
channels : {
GUILD _TEXT : { value : true } ,
GUILD _VOICE : { value : true } ,
GUILD _ANNOUNCEMENT : { value : true } ,
GUILD _STORE : { value : true } ,
GUILD _STAGE _VOICE : { value : true }
2020-09-19 20:49:33 +02:00
}
} ;
2019-11-14 14:17:57 +01:00
2020-09-19 20:49:33 +02:00
this . patchedModules = {
before : {
Channels : "render" ,
2021-02-05 12:59:29 +01:00
ChannelCategoryItem : "type" ,
VoiceUsers : "render"
2020-09-19 20:49:33 +02:00
} ,
after : {
2020-10-31 21:19:51 +01:00
ChannelItem : "default"
2020-09-19 20:49:33 +02:00
}
} ;
2020-10-17 15:39:40 +02:00
this . css = `
$ { BDFDB . dotCNS . _showhiddenchannelsaccessmodal + BDFDB . dotCN . messagespopoutemptyplaceholder } {
position : absolute ;
bottom : 0 ;
width : 100 % ;
}
` ;
2020-03-13 12:28:36 +01:00
}
2020-09-19 20:49:33 +02:00
2021-01-06 12:38:36 +01:00
onStart ( ) {
2021-01-13 19:28:23 +01:00
let loadedBlackList = BDFDB . DataUtils . load ( this , "blacklist" ) ;
this . saveBlackList ( ! BDFDB . ArrayUtils . is ( loadedBlackList ) ? [ ] : loadedBlackList ) ;
2020-03-13 12:28:36 +01:00
2021-01-13 19:28:23 +01:00
let loadedCollapseList = BDFDB . DataUtils . load ( this , "categorydata" ) ;
this . saveCollapseList ( ! BDFDB . ArrayUtils . is ( loadedCollapseList ) ? [ ] : loadedCollapseList ) ;
2020-08-14 00:43:19 +02:00
2020-09-11 19:31:36 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryModules . UnreadChannelUtils , "hasUnread" , { after : e => {
2020-03-13 12:28:36 +01:00
return e . returnValue && ! this . isChannelHidden ( e . methodArguments [ 0 ] ) ;
} } ) ;
2020-09-11 19:31:36 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryModules . UnreadChannelUtils , "getMentionCount" , { after : e => {
2020-03-13 12:28:36 +01:00
return this . isChannelHidden ( e . methodArguments [ 0 ] ) ? 0 : e . returnValue ;
} } ) ;
2020-09-11 19:31:36 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryModules . CategoryCollapseStore , "isCollapsed" , { after : e => {
2021-01-13 19:28:23 +01:00
if ( e . methodArguments [ 0 ] && e . methodArguments [ 0 ] . endsWith ( "hidden" ) ) {
2021-05-07 12:09:11 +02:00
if ( this . settings . general . alwaysCollapse && e . methodArguments [ 0 ] != lastGuildId && ! collapseList . includes ( e . methodArguments [ 0 ] ) ) {
2021-01-13 19:28:23 +01:00
collapseList . push ( e . methodArguments [ 0 ] ) ;
this . saveCollapseList ( BDFDB . ArrayUtils . removeCopies ( collapseList ) ) ;
}
lastGuildId = e . methodArguments [ 0 ] ;
return collapseList . includes ( e . methodArguments [ 0 ] ) ;
}
2020-03-13 12:28:36 +01:00
} } ) ;
2020-09-11 19:31:36 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryModules . CategoryCollapseUtils , "categoryCollapse" , { before : e => {
2020-03-13 12:28:36 +01:00
if ( e . methodArguments [ 0 ] && e . methodArguments [ 0 ] . endsWith ( "hidden" ) ) {
2021-01-13 19:28:23 +01:00
if ( ! collapseList . includes ( e . methodArguments [ 0 ] ) ) {
collapseList . push ( e . methodArguments [ 0 ] ) ;
this . saveCollapseList ( BDFDB . ArrayUtils . removeCopies ( collapseList ) ) ;
2020-03-13 12:28:36 +01:00
}
2019-11-14 14:17:57 +01:00
}
2020-03-13 12:28:36 +01:00
} } ) ;
2020-09-11 19:31:36 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryModules . CategoryCollapseUtils , "categoryExpand" , { before : e => {
2020-03-13 12:28:36 +01:00
if ( e . methodArguments [ 0 ] && e . methodArguments [ 0 ] . endsWith ( "hidden" ) ) {
2021-01-13 19:28:23 +01:00
if ( collapseList . includes ( e . methodArguments [ 0 ] ) ) {
BDFDB . ArrayUtils . remove ( collapseList , e . methodArguments [ 0 ] , true ) ;
this . saveCollapseList ( BDFDB . ArrayUtils . removeCopies ( collapseList ) ) ;
2020-03-13 12:28:36 +01:00
}
2019-11-14 14:17:57 +01:00
}
2020-03-13 12:28:36 +01:00
} } ) ;
2020-09-11 19:31:36 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryModules . GuildChannelStore , "getTextChannelNameDisambiguations" , { after : e => {
2021-02-04 19:07:37 +01:00
let all = this . getAllChannels ( ) ;
2020-03-13 12:28:36 +01:00
for ( let channel _id in all ) if ( all [ channel _id ] . guild _id == e . methodArguments [ 0 ] && ! e . returnValue [ channel _id ] && ( all [ channel _id ] . type != BDFDB . DiscordConstants . ChannelTypes . GUILD _CATEGORY && all [ channel _id ] . type != BDFDB . DiscordConstants . ChannelTypes . GUILD _VOICE ) ) e . returnValue [ channel _id ] = { id : channel _id , name : all [ channel _id ] . name } ;
} } ) ;
2021-05-12 12:27:54 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryModules . ChannelIconUtils , "getChannelIconComponent" , { before : e => {
if ( e . methodArguments [ 2 ] && e . methodArguments [ 2 ] . locked && e . methodArguments [ 0 ] && this . isChannelHidden ( e . methodArguments [ 0 ] . id ) ) e . methodArguments [ 2 ] . locked = false ;
} } ) ;
2019-01-26 22:45:19 +01:00
2020-08-29 09:02:00 +02:00
this . forceUpdateAll ( ) ;
2020-03-13 12:28:36 +01:00
}
2020-09-19 20:49:33 +02:00
2021-01-06 12:38:36 +01:00
onStop ( ) {
2020-08-29 09:02:00 +02:00
this . forceUpdateAll ( ) ;
2020-03-13 12:28:36 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
getSettingsPanel ( collapseStates = { } ) {
2021-05-07 12:09:11 +02:00
let settingsPanel ;
return settingsPanel = BDFDB . PluginUtils . createSettingsPanel ( this , {
2020-09-19 20:49:33 +02:00
collapseStates : collapseStates ,
2021-05-07 12:09:11 +02:00
children : _ => {
let settingsItems = [ ] ;
2020-09-19 20:49:33 +02:00
2021-06-15 11:48:34 +02:00
for ( let key in this . defaults . selections ) settingsItems . push ( ) ;
2021-05-07 12:09:11 +02:00
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . CollapseContainer , {
title : "Settings" ,
collapseStates : collapseStates ,
2021-06-15 11:48:34 +02:00
children : Object . keys ( this . defaults . sortOrder ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
type : "Select" ,
plugin : this ,
keys : [ "sortOrder" , key ] ,
label : this . defaults . sortOrder [ key ] . description ,
basis : "50%" ,
options : this . defaults . sortOrder [ key ] . options ,
value : this . settings . sortOrder [ key ]
} ) ) . concat ( Object . keys ( this . defaults . general ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
2021-05-07 12:09:11 +02:00
type : "Switch" ,
plugin : this ,
keys : [ "general" , key ] ,
label : this . defaults . general [ key ] . description ,
value : this . settings . general [ key ]
2021-06-15 11:48:34 +02:00
} ) ) ) . concat ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsPanelList , {
2021-05-07 12:09:11 +02:00
title : "Show Channels:" ,
children : Object . keys ( this . defaults . channels ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
type : "Switch" ,
plugin : this ,
keys : [ "channels" , key ] ,
label : BDFDB . LanguageUtils . LanguageStrings [ typeNameMap [ key ] ] ,
value : this . settings . channels [ key ]
} ) )
} ) )
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . CollapseContainer , {
title : "Server Black List" ,
collapseStates : collapseStates ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsGuildList , {
className : BDFDB . disCN . marginbottom20 ,
disabled : blackList ,
onClick : disabledGuilds => this . saveBlackList ( disabledGuilds )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsItem , {
type : "Button" ,
color : BDFDB . LibraryComponents . Button . Colors . GREEN ,
label : "Enable for all Servers" ,
onClick : _ => this . batchSetGuilds ( settingsPanel , collapseStates , true ) ,
children : BDFDB . LanguageUtils . LanguageStrings . ENABLE
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsItem , {
type : "Button" ,
color : BDFDB . LibraryComponents . Button . Colors . PRIMARY ,
label : "Disable for all Servers" ,
onClick : _ => this . batchSetGuilds ( settingsPanel , collapseStates , false ) ,
children : BDFDB . LanguageUtils . LanguageStrings . DISABLE
} )
]
} ) ) ;
return settingsItems ;
}
} ) ;
}
2020-09-19 20:49:33 +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 ( ) ;
2019-11-13 08:48:45 +01:00
}
2019-11-12 23:52:22 +01:00
}
2020-05-06 11:20:03 +02:00
2021-05-07 12:09:11 +02:00
forceUpdateAll ( ) {
2020-09-28 18:07:09 +02:00
hiddenChannelCache = { } ;
2020-08-14 00:36:42 +02:00
2020-09-19 20:49:33 +02:00
BDFDB . PatchUtils . forceAllUpdates ( this ) ;
2020-10-31 21:19:51 +01:00
BDFDB . ChannelUtils . rerenderAll ( ) ;
2020-08-14 00:36:42 +02:00
}
2020-09-19 20:49:33 +02:00
onChannelContextMenu ( e ) {
if ( e . instance . props . channel ) {
if ( e . instance . props . channel . id . endsWith ( "hidden" ) && e . instance . props . channel . type == BDFDB . DiscordConstants . ChannelTypes . GUILD _CATEGORY ) {
let [ children , index ] = BDFDB . ReactUtils . findParent ( e . returnvalue , { name : "ChannelMuteItem" } ) ;
if ( index > - 1 ) children . splice ( index , 1 ) ;
2021-06-15 13:05:28 +02:00
[ children , index ] = BDFDB . ContextMenuUtils . findItem ( e . returnvalue , { id : "mark-channel-read" , group : true } ) ;
children . splice ( index > - 1 ? index + 1 : 0 , 0 , BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
children : BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
label : this . labels . context _changeorder ,
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "change_order" ) ,
children : Object . keys ( sortOrders ) . filter ( n => sortOrders [ n ] . value != sortOrders . EXTRA . value ) . map ( n => BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
children : BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
label : this . labels [ "context_changeorder_" + sortOrders [ n ] . value ] ,
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "change_order" , sortOrders [ n ] . value ) ,
action : _ => {
this . settings . sortOrder . hidden = sortOrders [ n ] . value ;
BDFDB . DataUtils . save ( this . settings . sortOrder , this , "sortOrder" ) ;
this . forceUpdateAll ( ) ;
}
} )
} ) )
} )
} ) ) ;
2020-09-19 20:49:33 +02:00
}
let isHidden = this . isChannelHidden ( e . instance . props . channel . id ) ;
2021-05-07 12:09:11 +02:00
if ( isHidden || this . settings . general . showForNormal ) {
2020-09-19 20:49:33 +02:00
let [ children , index ] = BDFDB . ContextMenuUtils . findItem ( e . returnvalue , { id : "mark-channel-read" , group : true } ) ;
children . splice ( index > - 1 ? index + 1 : 0 , 0 , BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
children : BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2021-06-15 12:10:56 +02:00
label : this . labels . context _channelaccess ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "permissions" ) ,
2021-05-03 19:28:04 +02:00
action : _ => this . openAccessModal ( e . instance . props . channel , ! isHidden )
2020-09-19 20:49:33 +02:00
} )
} ) ) ;
}
2020-05-11 15:59:06 +02:00
}
2020-09-19 20:49:33 +02:00
}
onGuildContextMenu ( e ) {
if ( e . instance . props . guild ) {
let [ children , index ] = BDFDB . ContextMenuUtils . findItem ( e . returnvalue , { id : "hide-muted-channels" } ) ;
if ( index > - 1 ) children . splice ( index + 1 , 0 , BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuCheckboxItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _hidehidden ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "hide-locked-channels" ) ,
2021-01-13 19:28:23 +01:00
checked : blackList . includes ( e . instance . props . guild . id ) ,
2020-09-19 20:49:33 +02:00
action : value => {
2021-01-13 19:28:23 +01:00
if ( value ) blackList . push ( e . instance . props . guild . id ) ;
else BDFDB . ArrayUtils . remove ( blackList , e . instance . props . guild . id , true ) ;
this . saveBlackList ( BDFDB . ArrayUtils . removeCopies ( blackList ) ) ;
2020-09-19 20:49:33 +02:00
BDFDB . PatchUtils . forceAllUpdates ( this ) ;
2020-10-31 21:19:51 +01:00
BDFDB . ChannelUtils . rerenderAll ( true ) ;
2020-09-19 20:49:33 +02:00
}
} ) ) ;
2019-11-12 23:52:22 +01:00
}
2020-09-19 20:49:33 +02:00
}
onGuildHeaderContextMenu ( e ) {
this . onGuildContextMenu ( e ) ;
}
processChannels ( e ) {
2021-01-13 19:28:23 +01:00
if ( ! e . instance . props . guild || blackList . includes ( e . instance . props . guild . id ) ) return ;
2020-09-19 20:49:33 +02:00
let [ hiddenChannels , amount ] = this . getHiddenChannels ( e . instance . props . guild ) ;
if ( amount ) {
e . instance . props . categories = Object . assign ( { } , e . instance . props . categories ) ;
for ( let catId in e . instance . props . categories ) e . instance . props . categories [ catId ] = [ ] . concat ( e . instance . props . categories [ catId ] ) ;
e . instance . props . channels = Object . assign ( { } , e . instance . props . channels ) ;
for ( let type in e . instance . props . channels ) e . instance . props . channels [ type ] = [ ] . concat ( e . instance . props . channels [ type ] ) ;
let hiddenId = e . instance . props . guild . id + "_hidden" ;
2020-03-13 12:28:36 +01:00
2020-09-19 20:49:33 +02:00
delete e . instance . props . categories [ hiddenId ] ;
e . instance . props . categories . _categories = e . instance . props . categories . _categories . filter ( n => n . channel . id != hiddenId ) ;
e . instance . props . channels [ BDFDB . DiscordConstants . ChannelTypes . GUILD _CATEGORY ] = e . instance . props . channels [ BDFDB . DiscordConstants . ChannelTypes . GUILD _CATEGORY ] . filter ( n => n . channel . id != hiddenId ) ;
let index = - 1 ;
for ( let catId in e . instance . props . categories ) {
if ( catId != "_categories" ) e . instance . props . categories [ catId ] = e . instance . props . categories [ catId ] . filter ( n => ! this . isChannelHidden ( n . channel . id ) ) ;
for ( let channelObj of e . instance . props . categories [ catId ] ) if ( channelObj . index > index ) index = parseInt ( channelObj . index ) ;
}
2021-06-15 11:48:34 +02:00
if ( this . settings . sortOrder . hidden == sortOrders . EXTRA . value ) {
2020-09-19 20:49:33 +02:00
hiddenCategory = new BDFDB . DiscordObjects . Channel ( {
guild _id : e . instance . props . guild . id ,
id : hiddenId ,
2021-04-01 18:39:59 +02:00
name : "hidden" ,
2020-09-19 20:49:33 +02:00
type : BDFDB . DiscordConstants . ChannelTypes . GUILD _CATEGORY
} ) ;
e . instance . props . categories [ hiddenId ] = [ ] ;
e . instance . props . categories . _categories . push ( {
channel : hiddenCategory ,
index : ++ index
2020-05-11 15:59:06 +02:00
} ) ;
2020-09-19 20:49:33 +02:00
e . instance . props . channels [ BDFDB . DiscordConstants . ChannelTypes . GUILD _CATEGORY ] . push ( {
comparator : ( e . instance . props . channels [ BDFDB . DiscordConstants . ChannelTypes . GUILD _CATEGORY ] [ e . instance . props . channels [ BDFDB . DiscordConstants . ChannelTypes . GUILD _CATEGORY ] . length - 1 ] || { comparator : 0 } ) . comparator + 1 ,
channel : hiddenCategory
2020-05-11 15:59:06 +02:00
} ) ;
2020-03-13 12:28:36 +01:00
}
2020-09-19 20:49:33 +02:00
else hiddenCategory = null ;
2021-05-07 12:09:11 +02:00
2020-09-19 20:49:33 +02:00
for ( let type in hiddenChannels ) {
2021-05-07 12:09:11 +02:00
let channelType = channelGroupMap [ BDFDB . DiscordConstants . ChannelTypes [ type ] ] || type ;
2020-09-19 20:49:33 +02:00
if ( ! BDFDB . ArrayUtils . is ( e . instance . props . channels [ channelType ] ) ) e . instance . props . channels [ channelType ] = [ ] ;
for ( let channel of hiddenChannels [ type ] ) {
let hiddenChannel = new BDFDB . DiscordObjects . Channel ( Object . assign ( { } , channel , {
2021-06-15 11:48:34 +02:00
parent _id : hiddenCategory ? hiddenId : channel . parent _id ,
position : this . settings . sortOrder . hidden == sortOrders . BOTTOM . value ? 999999999 : channel . position
2020-09-19 20:49:33 +02:00
} ) ) ;
let parent _id = hiddenChannel . parent _id || "null" ;
e . instance . props . categories [ parent _id ] . push ( {
channel : hiddenChannel ,
index : hiddenChannel . position
} ) ;
e . instance . props . channels [ channelType ] . push ( {
comparator : hiddenChannel . position ,
channel : hiddenChannel
} ) ;
}
}
for ( let parent _id in e . instance . props . categories ) BDFDB . ArrayUtils . keySort ( e . instance . props . categories [ parent _id ] , "index" ) ;
for ( let channelType in e . instance . props . channels ) BDFDB . ArrayUtils . keySort ( e . instance . props . channels [ channelType ] , "comparator" ) ;
2020-03-13 12:28:36 +01:00
}
2019-11-12 22:28:33 +01:00
}
2020-09-19 20:49:33 +02:00
processChannelCategoryItem ( e ) {
if ( hiddenCategory && e . instance . props . channel && ! e . instance . props . channel . id && e . instance . props . channel . type != BDFDB . DiscordConstants . ChannelTypes . GUILD _CATEGORY ) e . instance . props . channel = hiddenCategory ;
2020-03-13 12:28:36 +01:00
}
2020-09-19 20:49:33 +02:00
processChannelItem ( e ) {
if ( e . instance . props . channel && this . isChannelHidden ( e . instance . props . channel . id ) ) {
2021-05-12 12:27:54 +02:00
let [ children , index ] = BDFDB . ReactUtils . findParent ( e . returnvalue , { name : "ChannelItemIcon" } ) ;
2020-11-19 16:51:14 +01:00
let channelChildren = BDFDB . ReactUtils . findChild ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . channelchildren ] ] } ) ;
2020-10-31 21:19:51 +01:00
if ( channelChildren && channelChildren . props && channelChildren . props . children ) {
channelChildren . props . children = [ BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TooltipContainer , {
text : BDFDB . LanguageUtils . LanguageStrings . CHANNEL _LOCKED _SHORT ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Clickable , {
2020-11-18 17:51:23 +01:00
className : BDFDB . disCN . channeliconitem ,
style : { display : "block" } ,
2020-10-31 21:19:51 +01:00
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SvgIcon , {
className : BDFDB . disCN . channelactionicon ,
name : BDFDB . LibraryComponents . SvgIcon . Names . LOCK _CLOSED
2020-03-13 12:28:36 +01:00
} )
2020-10-31 21:19:51 +01:00
} )
} ) ] ;
}
2021-01-13 19:28:23 +01:00
if ( ! ( e . instance . props . channel . type == BDFDB . DiscordConstants . ChannelTypes . GUILD _VOICE && e . instance . props . connected ) ) {
let wrapper = BDFDB . ReactUtils . findChild ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . channelwrapper ] ] } ) ;
if ( wrapper ) {
wrapper . props . onMouseDown = _ => { } ;
wrapper . props . onMouseUp = _ => { } ;
}
let mainContent = BDFDB . ReactUtils . findChild ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . channelmaincontent ] ] } ) ;
if ( mainContent ) {
mainContent . props . onClick = _ => { } ;
mainContent . props . href = null ;
}
2020-03-13 12:28:36 +01:00
}
2019-11-12 22:28:33 +01:00
}
}
2021-02-05 12:59:29 +01:00
processVoiceUsers ( e ) {
2021-05-07 12:09:11 +02:00
if ( ! this . settings . general . showVoiceUsers && this . isChannelHidden ( e . instance . props . channel . id ) ) e . instance . props . voiceStates = [ ] ;
2021-02-05 12:59:29 +01:00
}
2020-09-19 20:49:33 +02:00
isChannelHidden ( channelId ) {
2020-09-28 18:07:09 +02:00
let channel = BDFDB . LibraryModules . ChannelStore . getChannel ( channelId ) ;
return channel && hiddenChannelCache [ channel . guild _id ] && hiddenChannelCache [ channel . guild _id ] . hidden [ channel . type ] && hiddenChannelCache [ channel . guild _id ] . hidden [ channel . type ] . find ( c => c . id == channel . id ) ;
2020-09-19 20:49:33 +02:00
}
2021-02-04 19:07:37 +01:00
getAllChannels ( ) {
2021-04-13 17:26:58 +02:00
return ( BDFDB . LibraryModules . ChannelStore . getGuildChannels || BDFDB . LibraryModules . ChannelStore . getMutableGuildChannels || ( _ => ( { } ) ) ) ( ) ;
2021-02-04 19:07:37 +01:00
}
2020-09-19 20:49:33 +02:00
getHiddenChannels ( guild ) {
if ( ! guild ) return [ { } , 0 ] ;
2021-04-13 17:26:58 +02:00
let hiddenChannels = { } , visibleAmount = ( BDFDB . LibraryModules . GuildChannelStore . getChannels ( guild . id ) || { count : 0 } ) , count , rolesAmount = ( BDFDB . LibraryModules . MemberStore . getMember ( guild . id , BDFDB . UserUtils . me . id ) || { roles : [ ] } ) . roles . length ;
if ( ! hiddenChannelCache [ guild . id ] || hiddenChannelCache [ guild . id ] . visible != visibleAmount || hiddenChannelCache [ guild . id ] . roles != rolesAmount ) {
2021-02-04 19:07:37 +01:00
let all = this . getAllChannels ( ) ;
2021-02-03 10:44:40 +01:00
for ( let type in BDFDB . DiscordConstants . ChannelTypes ) hiddenChannels [ BDFDB . DiscordConstants . ChannelTypes [ type ] ] = [ ] ;
2020-09-19 20:49:33 +02:00
for ( let channel _id in all ) {
let channel = all [ channel _id ] ;
2021-05-07 12:09:11 +02:00
if ( channel . guild _id == guild . id && channel . type != BDFDB . DiscordConstants . ChannelTypes . GUILD _CATEGORY && ( this . settings . channels [ BDFDB . DiscordConstants . ChannelTypes [ channel . type ] ] || this . settings . channels [ BDFDB . DiscordConstants . ChannelTypes [ channel . type ] ] === undefined ) && ! BDFDB . DMUtils . isDMChannel ( channel . id ) && ! BDFDB . UserUtils . can ( "VIEW_CHANNEL" , BDFDB . UserUtils . me . id , channel . id ) ) hiddenChannels [ channel . type ] . push ( channel ) ;
2020-08-29 09:02:00 +02:00
}
2020-03-13 12:28:36 +01:00
}
2021-02-03 10:44:40 +01:00
else hiddenChannels = hiddenChannelCache [ guild . id ] . hidden ;
for ( let type in hiddenChannels ) hiddenChannels [ type ] = hiddenChannels [ type ] . filter ( c => BDFDB . LibraryModules . ChannelStore . getChannel ( c . id ) ) ;
2021-04-13 17:26:58 +02:00
hiddenChannelCache [ guild . id ] = { hidden : hiddenChannels , amount : BDFDB . ObjectUtils . toArray ( hiddenChannels ) . flat ( ) . length , visible : visibleAmount , roles : rolesAmount } ;
2021-02-03 10:44:40 +01:00
return [ hiddenChannelCache [ guild . id ] . hidden , hiddenChannelCache [ guild . id ] . amount ] ;
2019-11-12 22:28:33 +01:00
}
2020-09-19 20:49:33 +02:00
batchSetGuilds ( settingsPanel , collapseStates , value ) {
if ( ! value ) {
2021-01-13 19:28:23 +01:00
for ( let id of BDFDB . LibraryModules . FolderStore . getFlattenedGuildIds ( ) ) blackList . push ( id ) ;
this . saveBlackList ( BDFDB . ArrayUtils . removeCopies ( blackList ) ) ;
2020-09-19 20:49:33 +02:00
}
2021-01-13 19:28:23 +01:00
else this . saveBlackList ( [ ] ) ;
2020-09-19 20:49:33 +02:00
BDFDB . PluginUtils . refreshSettingsPanel ( this , settingsPanel , collapseStates ) ;
2019-01-17 23:48:29 +01:00
}
2020-09-19 20:49:33 +02:00
2021-01-13 19:28:23 +01:00
saveBlackList ( savedBlackList ) {
blackList = savedBlackList ;
BDFDB . DataUtils . save ( savedBlackList , this , "blacklist" ) ;
2020-09-19 20:49:33 +02:00
}
2021-01-13 19:28:23 +01:00
saveCollapseList ( savedCollapseList ) {
collapseList = savedCollapseList ;
BDFDB . DataUtils . save ( savedCollapseList , this , "categorydata" ) ;
2020-09-19 20:49:33 +02:00
}
2020-10-17 15:39:40 +02:00
openAccessModal ( channel , allowed ) {
2020-09-19 20:49:33 +02:00
let guild = BDFDB . LibraryModules . GuildStore . getGuild ( channel . guild _id ) ;
let myMember = guild && BDFDB . LibraryModules . MemberStore . getMember ( guild . id , BDFDB . UserUtils . me . id ) ;
2020-11-10 23:29:13 +01:00
let category = BDFDB . LibraryModules . ChannelStore . getChannel ( BDFDB . LibraryModules . ChannelStore . getChannel ( channel . id ) . parent _id ) ;
let lightTheme = BDFDB . DiscordUtils . getTheme ( ) == BDFDB . disCN . themelight ;
2021-01-25 18:23:02 +01:00
let addUser = ( id , users ) => {
let user = BDFDB . LibraryModules . UserStore . getUser ( id ) ;
if ( user ) allowedUsers . push ( Object . assign ( { } , user , BDFDB . LibraryModules . MemberStore . getMember ( guild . id , id ) || { } ) ) ;
else users . push ( { id : id , username : ` UserId: ${ id } ` , fetchable : true } ) ;
} ;
let checkPerm = permString => {
return ( ( permString | BDFDB . DiscordConstants . Permissions . VIEW _CHANNEL ) == permString || ( permString | BDFDB . DiscordConstants . Permissions . READ _MESSAGE _HISTORY ) == permString || channel . type == BDFDB . DiscordConstants . ChannelTypes . GUILD _VOICE && ( permString | BDFDB . DiscordConstants . Permissions . CONNECT ) == permString ) ;
} ;
2020-11-10 23:29:13 +01:00
let allowedRoles = [ ] , allowedUsers = [ ] , deniedRoles = [ ] , deniedUsers = [ ] , everyoneDenied = false ;
for ( let id in channel . permissionOverwrites ) {
2021-01-25 18:23:02 +01:00
if ( ( channel . permissionOverwrites [ id ] . type == BDFDB . DiscordConstants . PermissionOverrideType . ROLE || overrideTypes [ channel . permissionOverwrites [ id ] . type ] == BDFDB . DiscordConstants . PermissionOverrideType . ROLE ) && ( guild . roles [ id ] && guild . roles [ id ] . name != "@everyone" ) && checkPerm ( channel . permissionOverwrites [ id ] . allow ) ) {
2020-11-10 23:29:13 +01:00
allowedRoles . push ( Object . assign ( { overwritten : myMember && myMember . roles . includes ( id ) && ! allowed } , guild . roles [ id ] ) ) ;
}
2021-01-25 18:23:02 +01:00
else if ( ( channel . permissionOverwrites [ id ] . type == BDFDB . DiscordConstants . PermissionOverrideType . MEMBER || overrideTypes [ channel . permissionOverwrites [ id ] . type ] == BDFDB . DiscordConstants . PermissionOverrideType . MEMBER ) && checkPerm ( channel . permissionOverwrites [ id ] . allow ) ) {
addUser ( id , allowedUsers ) ;
2020-03-13 12:28:36 +01:00
}
2021-01-25 18:23:02 +01:00
if ( ( channel . permissionOverwrites [ id ] . type == BDFDB . DiscordConstants . PermissionOverrideType . ROLE || overrideTypes [ channel . permissionOverwrites [ id ] . type ] == BDFDB . DiscordConstants . PermissionOverrideType . ROLE ) && checkPerm ( channel . permissionOverwrites [ id ] . deny ) ) {
2020-11-10 23:29:13 +01:00
deniedRoles . push ( guild . roles [ id ] ) ;
if ( guild . roles [ id ] && guild . roles [ id ] . name == "@everyone" ) everyoneDenied = true ;
}
2021-01-25 18:23:02 +01:00
else if ( ( channel . permissionOverwrites [ id ] . type == BDFDB . DiscordConstants . PermissionOverrideType . MEMBER || overrideTypes [ channel . permissionOverwrites [ id ] . type ] == BDFDB . DiscordConstants . PermissionOverrideType . MEMBER ) && checkPerm ( channel . permissionOverwrites [ id ] . den ) ) {
addUser ( id , deniedUsers ) ;
2020-11-10 23:29:13 +01:00
}
}
2021-01-25 18:23:02 +01:00
if ( ! [ ] . concat ( allowedUsers , deniedUsers ) . find ( user => user . id == guild . ownerId ) ) addUser ( guild . ownerId , allowedUsers ) ;
for ( let id in guild . roles ) if ( ( guild . roles [ id ] . permissions | BDFDB . DiscordConstants . Permissions . ADMINISTRATOR ) == guild . roles [ id ] . permissions && ! [ ] . concat ( allowedRoles , deniedRoles ) . find ( role => role . id == id ) ) allowedRoles . push ( Object . assign ( { overwritten : myMember && myMember . roles . includes ( id ) && ! allowed } , guild . roles [ id ] ) ) ;
2020-11-10 23:29:13 +01:00
if ( allowed && ! everyoneDenied ) allowedRoles . push ( { name : "@everyone" } ) ;
2021-01-25 18:23:02 +01:00
2020-11-10 23:29:13 +01:00
let allowedElements = [ ] , deniedElements = [ ] ;
2021-02-04 19:46:29 +01:00
for ( let role of allowedRoles ) allowedElements . push ( BDFDB . ReactUtils . createElement ( RoleRowComponent , { role : role , guildId : guild . id , channelId : channel . id } ) ) ;
for ( let user of allowedUsers ) allowedElements . push ( BDFDB . ReactUtils . createElement ( UserRowComponent , { user : user , guildId : guild . id , channelId : channel . id } ) ) ;
for ( let role of deniedRoles ) deniedElements . push ( BDFDB . ReactUtils . createElement ( RoleRowComponent , { role : role , guildId : guild . id , channelId : channel . id } ) ) ;
for ( let user of deniedUsers ) deniedElements . push ( BDFDB . ReactUtils . createElement ( UserRowComponent , { user : user , guildId : guild . id , channelId : channel . id } ) ) ;
2020-10-17 15:39:40 +02:00
2020-11-10 23:29:13 +01:00
BDFDB . ModalUtils . open ( this , {
size : "MEDIUM" ,
header : BDFDB . LanguageUtils . LanguageStrings . CHANNEL + " " + BDFDB . LanguageUtils . LanguageStrings . ACCESSIBILITY ,
2021-01-23 18:50:24 +01:00
subHeader : "#" + channel . name ,
2020-11-10 23:29:13 +01:00
className : BDFDB . disCN . _showhiddenchannelsaccessmodal ,
contentClassName : BDFDB . disCN . listscroller ,
2021-03-01 13:32:54 +01:00
onOpen : modalInstance => { if ( modalInstance ) accessModal = modalInstance ; } ,
2020-11-10 23:29:13 +01:00
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ModalComponents . ModalTabContent , {
className : BDFDB . disCN . modalsubinner ,
tab : BDFDB . LanguageUtils . LanguageStrings . OVERLAY _SETTINGS _GENERAL _TAB ,
children : [ {
title : BDFDB . LanguageUtils . LanguageStrings . FORM _LABEL _CHANNEL _NAME ,
text : channel . name
} , channel . type == BDFDB . DiscordConstants . ChannelTypes . GUILD _VOICE ? {
title : BDFDB . LanguageUtils . LanguageStrings . FORM _LABEL _BITRATE ,
text : channel . bitrate || "---"
} : {
title : BDFDB . LanguageUtils . LanguageStrings . FORM _LABEL _CHANNEL _TOPIC ,
2021-05-03 19:28:04 +02:00
text : BDFDB . ReactUtils . markdownParse ( channel . topic || "---" )
2020-11-10 23:29:13 +01:00
} , {
title : BDFDB . LanguageUtils . LanguageStrings . CHANNEL _TYPE ,
text : BDFDB . LanguageUtils . LanguageStrings [ typeNameMap [ BDFDB . DiscordConstants . ChannelTypes [ channel . type ] ] ]
} , {
title : BDFDB . LanguageUtils . LanguageStrings . CATEGORY _NAME ,
text : category && category . name || BDFDB . LanguageUtils . LanguageStrings . NO _CATEGORY
} ] . map ( ( formLabel , i ) => formLabel && [
i == 0 ? null : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormDivider , {
className : BDFDB . disCN . marginbottom20
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : ` ${ formLabel . title } : ` ,
className : BDFDB . DOMUtils . formatClassName ( BDFDB . disCN . marginbottom20 , i == 0 && BDFDB . disCN . margintop8 ) ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormText , {
className : BDFDB . disCN . marginleft8 ,
children : formLabel . text
2020-03-13 12:28:36 +01:00
} )
2020-09-19 20:49:33 +02:00
} )
2020-11-10 23:29:13 +01:00
] ) . flat ( 10 ) . filter ( n => n )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ModalComponents . ModalTabContent , {
2020-12-21 19:56:36 +01:00
tab : this . labels . modal _allowed ,
2020-11-10 23:29:13 +01:00
children : allowedElements . length ? allowedElements :
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . MessagesPopoutComponents . EmptyStateBottom , {
msg : BDFDB . LanguageUtils . LanguageStrings . AUTOCOMPLETE _NO _RESULTS _HEADER ,
image : lightTheme ? "/assets/9b0d90147f7fab54f00dd193fe7f85cd.svg" : "/assets/308e587f3a68412f137f7317206e92c2.svg"
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ModalComponents . ModalTabContent , {
2020-12-21 19:56:36 +01:00
tab : this . labels . modal _denied ,
2020-11-10 23:29:13 +01:00
children : deniedElements . length ? deniedElements :
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . MessagesPopoutComponents . EmptyStateBottom , {
msg : BDFDB . LanguageUtils . LanguageStrings . AUTOCOMPLETE _NO _RESULTS _HEADER ,
image : lightTheme ? "/assets/9b0d90147f7fab54f00dd193fe7f85cd.svg" : "/assets/308e587f3a68412f137f7317206e92c2.svg"
} )
} )
]
} ) ;
2020-03-13 12:28:36 +01:00
}
2019-01-26 22:45:19 +01: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-06-15 13:05:28 +02:00
context _changeorder : "Промяна на реда на скритите канали" ,
context _changeorder _bottom : "Родна категория в долната част" ,
context _changeorder _native : "Родна категория в правилен ред" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Достъп до канал" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Скриване на заключените канали" ,
modal _allowed : "Разрешено" ,
modal _denied : "Отрича с е "
2020-09-19 20:49:33 +02:00
} ;
2021-06-15 12:10:56 +02:00
case "cs" : // Czech
return {
2021-06-15 13:05:28 +02:00
context _changeorder : "Změnit pořadí skrytých kanálů" ,
context _changeorder _bottom : "Nativní kategorie dole" ,
context _changeorder _native : "Nativní kategorie ve správném pořadí" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Přístup ke kanálu" ,
context _hidehidden : "Skrýt zamčené kanály" ,
modal _allowed : "Povoleno" ,
modal _denied : "Odepřeno"
} ;
2020-12-21 19:56:36 +01:00
case "da" : // Danish
2020-09-19 20:49:33 +02:00
return {
2021-06-15 13:05:28 +02:00
context _changeorder : "Skift rækkefølge for skjulte kanaler" ,
context _changeorder _bottom : "Indfødt kategori i bunden" ,
context _changeorder _native : "Native Kategori i korrekt rækkefølge" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Kanaltilgang" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Skjul låste kanaler" ,
modal _allowed : "Tilladt" ,
modal _denied : "Nægtet"
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-06-15 13:05:28 +02:00
context _changeorder : "Reihenfolge der versteckten Kanäle ändern" ,
context _changeorder _bottom : "Native Kategorie ganz unten" ,
context _changeorder _native : "Native Kategorie in der richtigen Reihenfolge" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Kanalzugriff" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Versteckte Kanäle ausblenden" ,
modal _allowed : "Erlaubt" ,
modal _denied : "Verweigert"
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-06-15 13:05:28 +02:00
context _changeorder : "Αλλαγή σειράς κρυφών καναλιών" ,
context _changeorder _bottom : "Εγγενής κατηγορία στο κάτω μέρος" ,
context _changeorder _native : "Εγγενής κατηγορία σε σωστή σειρά" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Πρόσβαση καναλιού" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Απόκρυψη κλειδωμένων καναλιών" ,
modal _allowed : "Επιτρεπόμενο" ,
modal _denied : "Απορρίφθηκε"
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-06-15 13:05:28 +02:00
context _changeorder : "Cambiar el orden de los canales ocultos" ,
context _changeorder _bottom : "Categoría nativa en la parte inferior" ,
context _changeorder _native : "Categoría nativa en el orden correcto" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Acceso al canal" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Ocultar canales bloqueados" ,
modal _allowed : "Permitido" ,
modal _denied : "Negado"
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-06-15 13:05:28 +02:00
context _changeorder : "Muuta piilotettujen kanavien järjestystä" ,
context _changeorder _bottom : "Alkuperäinen luokka alareunassa" ,
context _changeorder _native : "Alkuperäinen luokka oikeassa järjestyksessä" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Kanavan käyttöoikeus" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Piilota lukitut kanavat" ,
modal _allowed : "Sallittu" ,
modal _denied : "Kielletty"
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-06-15 13:05:28 +02:00
context _changeorder : "Modifier l'ordre des canaux cachés" ,
context _changeorder _bottom : "Catégorie native en bas" ,
context _changeorder _native : "Catégorie native dans le bon ordre" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Accès à la chaîne" ,
2021-03-20 16:19:13 +01:00
context _hidehidden : "Masquer les salons verrouillées" ,
2020-12-21 19:56:36 +01:00
modal _allowed : "Permis" ,
modal _denied : "Refusé"
2020-09-19 20:49:33 +02:00
} ;
2021-06-15 12:10:56 +02:00
case "hi" : // Hindi
return {
2021-06-15 13:05:28 +02:00
context _changeorder : "हिडन चैनल ऑर्डर बदलें" ,
context _changeorder _bottom : "नीचे की ओर मूल श्रेणी" ,
context _changeorder _native : "मूल श्रेणी सही क्रम में" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "चैनल एक्सेस" ,
context _hidehidden : "बंद चैनल छुपाएं Hide" ,
modal _allowed : "अनुमति है" ,
modal _denied : "निषेध"
} ;
2020-12-21 19:56:36 +01:00
case "hr" : // Croatian
2020-09-19 20:49:33 +02:00
return {
2021-06-15 13:05:28 +02:00
context _changeorder : "Promijenite redoslijed skrivenih kanala" ,
context _changeorder _bottom : "Izvorna kategorija na dnu" ,
context _changeorder _native : "Izvorna kategorija u ispravnom redoslijedu" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Pristup kanalu" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Sakrij zaključane kanale" ,
modal _allowed : "Dopuštena" ,
modal _denied : "Odbijen"
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-06-15 13:05:28 +02:00
context _changeorder : "Rejtett csatornák sorrendjének módosítása" ,
context _changeorder _bottom : "Natív kategória az alján" ,
context _changeorder _native : "Natív kategória helyes sorrendben" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Csatornához való hozzáférés" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Zárt csatornák elrejtése" ,
modal _allowed : "Megengedett" ,
modal _denied : "Megtagadva"
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-06-15 13:05:28 +02:00
context _changeorder : "Modifica l'ordine dei canali nascosti" ,
context _changeorder _bottom : "Categoria nativa in basso" ,
context _changeorder _native : "Categoria nativa nell'ordine corretto" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Accesso al canale" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Nascondi canali bloccati" ,
modal _allowed : "Consentito" ,
modal _denied : "Negato"
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-06-15 13:05:28 +02:00
context _changeorder : "非表示チャネルの順序を変更する" ,
context _changeorder _bottom : "下部のネイティブカテゴリ" ,
context _changeorder _native : "正しい順序のネイティブカテゴリ" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "チャネルアクセス" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "ロックされたチャンネルを非表示にする" ,
modal _allowed : "許可" ,
modal _denied : "拒否されました"
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-06-15 13:05:28 +02:00
context _changeorder : "숨겨진 채널 순서 변경" ,
context _changeorder _bottom : "하단의 기본 카테고리" ,
context _changeorder _native : "올바른 순서의 네이티브 카테고리" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "채널 액세스" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "잠긴 채널 숨기기" ,
modal _allowed : "허용됨" ,
modal _denied : "거부 됨"
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-06-15 13:05:28 +02:00
context _changeorder : "Keisti paslėptų kanalų tvarką" ,
context _changeorder _bottom : "Gimtoji kategorija apačioje" ,
context _changeorder _native : "Gimtoji kategorija teisinga tvarka" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Prieiga prie kanalo" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Slėpti užrakintus kanalus" ,
modal _allowed : "Leidžiama" ,
modal _denied : "Paneigta"
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-06-15 13:05:28 +02:00
context _changeorder : "Wijzig de volgorde van verborgen kanalen" ,
context _changeorder _bottom : "Native categorie onderaan" ,
context _changeorder _native : "Native categorie in de juiste volgorde" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Kanaaltoegang" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Verberg vergrendelde kanalen" ,
modal _allowed : "Toegestaan" ,
modal _denied : "Geweigerd"
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-06-15 13:05:28 +02:00
context _changeorder : "Endre rekkefølgen på skjulte kanaler" ,
context _changeorder _bottom : "Innfødt kategori nederst" ,
context _changeorder _native : "Innfødt kategori i riktig rekkefølge" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Kanaltilgang" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Skjul låste kanaler" ,
modal _allowed : "Tillatt" ,
modal _denied : "Nektet"
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-06-15 13:05:28 +02:00
context _changeorder : "Zmień kolejność ukrytych kanałów" ,
context _changeorder _bottom : "Kategoria natywna na dole" ,
context _changeorder _native : "Kategoria natywna we właściwej kolejności" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Dostęp do kanałów" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Ukryj zablokowane kanały" ,
modal _allowed : "Dozwolony" ,
modal _denied : "Odmówiono"
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-06-15 13:05:28 +02:00
context _changeorder : "Alterar a ordem dos canais ocultos" ,
context _changeorder _bottom : "Categoria nativa na parte inferior" ,
context _changeorder _native : "Categoria nativa na ordem correta" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Acesso ao canal" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Ocultar canais bloqueados" ,
modal _allowed : "Permitido" ,
modal _denied : "Negado"
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-06-15 13:05:28 +02:00
context _changeorder : "Schimbați comanda canalelor ascunse" ,
context _changeorder _bottom : "Categorie nativă în partea de jos" ,
context _changeorder _native : "Categorie nativă în ordine corectă" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Acces la canal" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Ascundeți canalele blocate" ,
modal _allowed : "Permis" ,
modal _denied : "Negat"
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-06-15 13:05:28 +02:00
context _changeorder : "Изменить порядок скрытых каналов" ,
context _changeorder _bottom : "Родная категория внизу" ,
context _changeorder _native : "Собственная категория в правильном порядке" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Доступ к каналу" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Скрыть заблокированные каналы" ,
modal _allowed : "Разрешенный" ,
modal _denied : "Отказано"
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-06-15 13:05:28 +02:00
context _changeorder : "Ändra ordning för dolda kanaler" ,
context _changeorder _bottom : "Naturlig kategori längst ner" ,
context _changeorder _native : "Naturlig kategori i rätt ordning" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Kanaltillgång" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Dölj låsta kanaler" ,
modal _allowed : "Tillåtet" ,
modal _denied : "Förnekad"
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-06-15 13:05:28 +02:00
context _changeorder : "เปลี่ยนลำดับช่องที่ซ่อนอยู่" ,
context _changeorder _bottom : "หมวดหมู่ดั้งเดิมที่ด้านล่าง" ,
context _changeorder _native : "หมวดหมู่ดั้งเดิมในลำดับที่ถูกต้อง" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "การเข้าถึงช่อง" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "ซ่อนช่องที่ถูกล็อก" ,
modal _allowed : "ได้รับอนุญาต" ,
modal _denied : "ถูกปฏิเสธ"
} ;
case "tr" : // Turkish
return {
2021-06-15 13:05:28 +02:00
context _changeorder : "Gizli Kanal Sı rası nı Değiştir" ,
context _changeorder _bottom : "Altta Yerel Kategori" ,
context _changeorder _native : "Yerel Kategori doğru sı rada" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Kanal Erişimi" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Kilitli Kanalları Gizle" ,
modal _allowed : "İzin veriliyor" ,
modal _denied : "Reddedildi"
} ;
case "uk" : // Ukrainian
return {
2021-06-15 13:05:28 +02:00
context _changeorder : "Змінити порядок прихованих каналів" ,
context _changeorder _bottom : "Рідна категорія внизу" ,
context _changeorder _native : "Рідна категорія в правильному порядку" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Доступ до каналу" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Сховати заблоковані канали" ,
modal _allowed : "Дозволено" ,
modal _denied : "Заперечується"
} ;
case "vi" : // Vietnamese
return {
2021-06-15 13:05:28 +02:00
context _changeorder : "Thay đổi thứ tự các kênh bị ẩn" ,
context _changeorder _bottom : "Danh mục Gốc ở dưới cùng" ,
context _changeorder _native : "Danh mục gốc theo đúng thứ tự" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Quyền truy cập kênh" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Ẩn các kênh đã khóa" ,
modal _allowed : "Được phép" ,
modal _denied : "Phủ định"
} ;
2021-01-15 17:54:22 +01:00
case "zh-CN" : // Chinese (China)
2020-12-21 19:56:36 +01:00
return {
2021-06-15 13:05:28 +02:00
context _changeorder : "更改隐藏频道顺序" ,
context _changeorder _bottom : "底部的原生类别" ,
context _changeorder _native : "正确顺序的本地类别" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "频道访问" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "隐藏锁定的频道" ,
modal _allowed : "允许的" ,
modal _denied : "被拒绝"
} ;
2021-01-15 17:54:22 +01:00
case "zh-TW" : // Chinese (Taiwan)
2020-12-21 19:56:36 +01:00
return {
2021-06-15 13:05:28 +02:00
context _changeorder : "更改隱藏頻道順序" ,
context _changeorder _bottom : "底部的原生類別" ,
context _changeorder _native : "正確順序的本地類別" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "頻道訪問" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "隱藏鎖定的頻道" ,
modal _allowed : "允許的" ,
modal _denied : "被拒絕"
} ;
default : // English
return {
2021-06-15 13:05:28 +02:00
context _changeorder : "Change Hidden Channels Order" ,
context _changeorder _bottom : "Native Category at the bottom" ,
context _changeorder _native : "Native Category in correct Order" ,
2021-06-15 12:10:56 +02:00
context _channelaccess : "Channel Access" ,
2020-12-21 19:56:36 +01:00
context _hidehidden : "Hide Locked Channels" ,
modal _allowed : "Permitted" ,
modal _denied : "Denied"
2020-09-19 20:49:33 +02:00
} ;
}
2020-03-13 12:28:36 +01:00
}
2020-09-19 20:49:33 +02:00
} ;
2020-10-09 21:09:35 +02:00
} ) ( window . BDFDB _Global . PluginUtils . buildPlugin ( config ) ) ;
2021-05-08 13:55:03 +02:00
} ) ( ) ;