Skip to content

Instantly share code, notes, and snippets.

@Commandcracker
Last active September 5, 2022 12:10
Show Gist options
  • Save Commandcracker/fad101e609bc5648de10e89c33fd4687 to your computer and use it in GitHub Desktop.
Save Commandcracker/fad101e609bc5648de10e89c33fd4687 to your computer and use it in GitHub Desktop.
Displays all hidden Channels, which can't be accessed due to Role Restrictions, this won't allow you to read them (impossible) [webarchive](https://web.archive.org/web/20220607233834/https://github.com/mwittrien/BetterDiscordAddons/blob/master/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js)
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
/**
* @name ShowHiddenChannels
* @author DevilBro
* @authorId 278543574059057154
* @version 3.1.2
* @description Displays all hidden Channels, which can't be accessed due to Role Restrictions, this won't allow you to read them (impossible)
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
* @patreon https://www.patreon.com/MircoWittrien
* @website https://mwittrien.github.io/
* @source https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ShowHiddenChannels/
* @updateUrl https://mwittrien.github.io/BetterDiscordAddons/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js
*/
module.exports = (_ => {
const config = {
"info": {
"name": "ShowHiddenChannels",
"author": "DevilBro",
"version": "3.1.2",
"description": "Displays all hidden Channels, which can't be accessed due to Role Restrictions, this won't allow you to read them (impossible)"
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return `The Library Plugin needed for ${config.info.name} is missing. Open the Plugin Settings to download it. \n\n${config.info.description}`;}
downloadLibrary () {
require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (e, r, b) => {
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"}));
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");
});
}
load () {
if (!window.BDFDB_Global || !Array.isArray(window.BDFDB_Global.pluginQueue)) window.BDFDB_Global = Object.assign({}, window.BDFDB_Global, {pluginQueue: []});
if (!window.BDFDB_Global.downloadModal) {
window.BDFDB_Global.downloadModal = true;
BdApi.showConfirmationModal("Library Missing", `The Library Plugin needed for ${config.info.name} is missing. Please click "Download Now" to install it.`, {
confirmText: "Download Now",
cancelText: "Cancel",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {
delete window.BDFDB_Global.downloadModal;
this.downloadLibrary();
}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start () {this.load();}
stop () {}
getSettingsPanel () {
let template = document.createElement("template");
template.innerHTML = `<div style="color: var(--header-primary); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The Library Plugin needed for ${config.info.name} is missing.\nPlease click <a style="font-weight: 500;">Download Now</a> to install it.</div>`;
template.content.firstElementChild.querySelector("a").addEventListener("click", this.downloadLibrary);
return template.content.firstElementChild;
}
} : (([Plugin, BDFDB]) => {
var blackList = [], collapseList = [], hiddenCategory, lastGuildId, overrideTypes = [];
var hiddenChannelCache = {};
var accessModal;
const channelGroupMap = {
GUILD_TEXT: "SELECTABLE",
GUILD_VOICE: "VOCAL",
GUILD_ANNOUNCEMENT: "SELECTABLE",
GUILD_STORE: "SELECTABLE",
GUILD_STAGE_VOICE: "VOCAL"
};
const typeNameMap = {
GUILD_TEXT: "TEXT_CHANNEL",
GUILD_VOICE: "VOICE_CHANNEL",
GUILD_ANNOUNCEMENT: "NEWS_CHANNEL",
GUILD_STORE: "STORE_CHANNEL",
GUILD_CATEGORY: "CATEGORY",
GUILD_STAGE_VOICE: "STAGE_CHANNEL",
PUBLIC_THREAD: "THREAD",
PRIVATE_THREAD: "PRIVATE_THREAD"
};
const sortOrders = {
NATIVE: {value: "native", label: "Native Category in correct Order"},
BOTTOM: {value: "bottom", label: "Native Category at the bottom"},
EXTRA: {value: "extra", label: "Extra Category 'Hidden'"}
};
const UserRowComponent = class UserRow extends BdApi.React.Component {
componentDidMount() {
if (this.props.user.fetchable) {
this.props.user.fetchable = false;
BDFDB.LibraryModules.UserProfileUtils.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);
});
}
}
render() {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ListRow, {
prefix: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.listavatar,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AvatarComponents.default, {
src: BDFDB.UserUtils.getAvatar(this.props.user.id),
status: BDFDB.UserUtils.getStatus(this.props.user.id),
size: BDFDB.LibraryComponents.AvatarComponents.Sizes.SIZE_40,
onClick: _ => {
if (accessModal) accessModal.props.onClose();
BDFDB.LibraryModules.UserProfileModalUtils.openUserProfileModal({
userId: this.props.user.id,
guildId: this.props.guildId
});
}
})
}),
labelClassName: BDFDB.disCN.nametag,
label: [
BDFDB.ReactUtils.createElement("span", {
className: BDFDB.disCN.username,
children: this.props.user.nick || this.props.user.username,
style: {color: this.props.user.colorString}
}),
!this.props.user.discriminator ? null : BDFDB.ReactUtils.createElement("span", {
className: BDFDB.disCN.listdiscriminator,
children: `#${this.props.user.discriminator}`
}),
this.props.user.bot && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.BotTag, {
style: {marginLeft: 6}
})
]
});
}
};
const RoleRowComponent = class RoleRow extends BdApi.React.Component {
render() {
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, "RGB") || BDFDB.DiscordConstants.Colors.PRIMARY_DARK_300
}
})
}),
labelClassName: this.props.role.overwritten && BDFDB.disCN.strikethrough,
label: BDFDB.ReactUtils.createElement("span", {
children: this.props.role.name,
style: {color: this.props.role.colorString}
})
});
}
};
return class ShowHiddenChannels extends Plugin {
onLoad () {
overrideTypes = Object.keys(BDFDB.DiscordConstants.PermissionOverrideType);
this.defaults = {
sortOrder: {
hidden: {
value: sortOrders[Object.keys(sortOrders)[0]].value,
description: "Sorts hidden Channels in",
options: Object.keys(sortOrders).map(n => sortOrders[n])
}
},
general: {
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"}
},
channels: {
GUILD_TEXT: {value: true},
GUILD_VOICE: {value: true},
GUILD_ANNOUNCEMENT: {value: true},
GUILD_STORE: {value: true},
GUILD_STAGE_VOICE: {value: true}
}
};
this.patchedModules = {
before: {
Channels: "render",
ChannelCategoryItem: "type",
ChannelItem: "default",
VoiceUsers: "render"
},
after: {
ChannelItem: "default"
}
};
this.css = `
${BDFDB.dotCNS._showhiddenchannelsaccessmodal + BDFDB.dotCN.messagespopoutemptyplaceholder} {
position: absolute;
bottom: 0;
width: 100%;
}
`;
}
onStart () {
this.saveBlackList(this.getBlackList());
let loadedCollapseList = BDFDB.DataUtils.load(this, "categorydata");
this.saveCollapseList(!BDFDB.ArrayUtils.is(loadedCollapseList) ? [] : loadedCollapseList);
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.GuildUtils, "setChannel", {instead: e => {
let channelId = (BDFDB.LibraryModules.VoiceUtils.getVoiceStateForUser(e.methodArguments[1]) || {}).channelId;
if (!channelId || !this.isChannelHidden(channelId)) return e.callOriginalMethod();
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.UnreadChannelUtils, "hasUnread", {after: e => {
return e.returnValue && !this.isChannelHidden(e.methodArguments[0]);
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.UnreadChannelUtils, "getMentionCount", {after: e => {
return this.isChannelHidden(e.methodArguments[0]) ? 0 : e.returnValue;
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.CategoryCollapseStore, "isCollapsed", {after: e => {
if (e.methodArguments[0] && e.methodArguments[0].endsWith("hidden")) {
if (this.settings.general.alwaysCollapse && e.methodArguments[0] != lastGuildId && !collapseList.includes(e.methodArguments[0])) {
collapseList.push(e.methodArguments[0]);
this.saveCollapseList(BDFDB.ArrayUtils.removeCopies(collapseList));
}
lastGuildId = e.methodArguments[0];
return collapseList.includes(e.methodArguments[0]);
}
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.CategoryCollapseUtils, "categoryCollapse", {before: e => {
if (e.methodArguments[0] && e.methodArguments[0].endsWith("hidden")) {
if (!collapseList.includes(e.methodArguments[0])) {
collapseList.push(e.methodArguments[0]);
this.saveCollapseList(BDFDB.ArrayUtils.removeCopies(collapseList));
}
}
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.CategoryCollapseUtils, "categoryExpand", {before: e => {
if (e.methodArguments[0] && e.methodArguments[0].endsWith("hidden")) {
if (collapseList.includes(e.methodArguments[0])) {
BDFDB.ArrayUtils.remove(collapseList, e.methodArguments[0], true);
this.saveCollapseList(BDFDB.ArrayUtils.removeCopies(collapseList));
}
}
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.GuildChannelStore, "getTextChannelNameDisambiguations", {after: e => {
let all = BDFDB.LibraryModules.ChannelStore.getMutableGuildChannelsForGuild(e.methodArguments[0]);
for (let channel_id in all) if (!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};
}});
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;
}});
this.forceUpdateAll();
}
onStop () {
this.forceUpdateAll();
}
getSettingsPanel (collapseStates = {}) {
let settingsPanel;
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
collapseStates: collapseStates,
children: _ => {
let settingsItems = [];
for (let key in this.defaults.selections) settingsItems.push();
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
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, {
type: "Switch",
plugin: this,
keys: ["general", key],
label: this.defaults.general[key].description,
value: this.settings.general[key]
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
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;
}
});
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
forceUpdateAll () {
hiddenChannelCache = {};
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.ChannelUtils.rerenderAll();
}
onUserContextMenu (e) {
if (e.subType == "useUserManagementItems" || e.subType == "useMoveUserVoiceItems" || e.subType == "usePreviewVideoItem") {
let channelId = (BDFDB.LibraryModules.VoiceUtils.getVoiceStateForUser(e.instance.props.user.id) || {}).channelId;
if (channelId && this.isChannelHidden(channelId)) return null;
}
}
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);
[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();
}
})
}))
})
}));
}
let isHidden = this.isChannelHidden(e.instance.props.channel.id);
if (isHidden) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "invite-people"});
if (index > -1) children.splice(index, 1);
}
if (isHidden || this.settings.general.showForNormal) {
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, {
label: this.labels.context_channelaccess,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "permissions"),
action: _ => this.openAccessModal(e.instance.props.channel, !isHidden)
})
}));
}
}
}
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, {
label: this.labels.context_hidehidden,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "hide-locked-channels"),
checked: blackList.includes(e.instance.props.guild.id),
action: value => {
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));
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.ChannelUtils.rerenderAll(true);
}
}));
}
}
onGuildHeaderContextMenu (e) {
this.onGuildContextMenu(e);
}
processChannels (e) {
if (!e.instance.props.guild || blackList.includes(e.instance.props.guild.id)) return;
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";
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);
}
if (this.settings.sortOrder.hidden == sortOrders.EXTRA.value) {
hiddenCategory = new BDFDB.DiscordObjects.Channel({
guild_id: e.instance.props.guild.id,
id: hiddenId,
name: "hidden",
type: BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY
});
e.instance.props.categories[hiddenId] = [];
e.instance.props.categories._categories.push({
channel: hiddenCategory,
index: ++index
});
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
});
}
else hiddenCategory = null;
for (let type in hiddenChannels) {
let channelType = channelGroupMap[BDFDB.DiscordConstants.ChannelTypes[type]] || type;
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, {
parent_id: hiddenCategory ? hiddenId : channel.parent_id,
position: this.settings.sortOrder.hidden == sortOrders.BOTTOM.value ? 999999999 : channel.position
}));
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");
}
}
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;
}
processChannelItem (e) {
if (e.instance.props.channel && !blackList.includes(e.instance.props.channel.guild_id) && this.isChannelHidden(e.instance.props.channel.id)) {
if (!e.returnvalue) e.instance.props.className = BDFDB.DOMUtils.formatClassName(e.instance.props.className, BDFDB.disCN._showhiddenchannelshiddenchannel);
else {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ChannelItemIcon"});
let channelChildren = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.channelchildren]]});
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, {
className: BDFDB.disCN.channeliconitem,
style: {display: "block"},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.channelactionicon,
name: BDFDB.LibraryComponents.SvgIcon.Names.LOCK_CLOSED
})
})
})];
}
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 = event => BDFDB.ListenerUtils.stopEvent(event);
wrapper.props.onMouseUp = event => BDFDB.ListenerUtils.stopEvent(event);
}
let mainContent = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.channelmaincontent]]});
if (mainContent) {
mainContent.props.onClick = event => BDFDB.ListenerUtils.stopEvent(event);
mainContent.props.href = null;
}
}
}
}
}
processVoiceUsers (e) {
if (!this.settings.general.showVoiceUsers && this.isChannelHidden(e.instance.props.channel.id)) e.instance.props.voiceStates = [];
}
isChannelHidden (channelId) {
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);
}
getHiddenChannels (guild) {
if (!guild) return [{}, 0];
let hiddenChannels = {}, visibleAmount = BDFDB.ArrayUtils.sum(BDFDB.ObjectUtils.toArray((BDFDB.LibraryModules.GuildChannelStore.getChannels(guild.id))).filter(BDFDB.ArrayUtils.is).map(n => n.length)), 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) {
let all = BDFDB.LibraryModules.ChannelStore.getMutableGuildChannelsForGuild(guild.id);
for (let type in BDFDB.DiscordConstants.ChannelTypes) hiddenChannels[BDFDB.DiscordConstants.ChannelTypes[type]] = [];
for (let channel_id in all) {
let channel = all[channel_id];
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);
}
}
else hiddenChannels = hiddenChannelCache[guild.id].hidden;
for (let type in hiddenChannels) hiddenChannels[type] = hiddenChannels[type].filter(c => BDFDB.LibraryModules.ChannelStore.getChannel(c.id));
hiddenChannelCache[guild.id] = {hidden: hiddenChannels, amount: BDFDB.ObjectUtils.toArray(hiddenChannels).flat().length, visible: visibleAmount, roles: rolesAmount};
return [hiddenChannelCache[guild.id].hidden, hiddenChannelCache[guild.id].amount];
}
batchSetGuilds (settingsPanel, collapseStates, value) {
if (!value) {
for (let id of BDFDB.LibraryModules.FolderStore.getFlattenedGuildIds()) blackList.push(id);
this.saveBlackList(BDFDB.ArrayUtils.removeCopies(blackList));
}
else this.saveBlackList([]);
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
}
getBlackList () {
let loadedBlackList = BDFDB.DataUtils.load(this, "blacklist");
return !BDFDB.ArrayUtils.is(loadedBlackList) ? [] : loadedBlackList;
}
saveBlackList (savedBlackList) {
blackList = savedBlackList;
BDFDB.DataUtils.save(savedBlackList, this, "blacklist");
}
saveCollapseList (savedCollapseList) {
collapseList = savedCollapseList;
BDFDB.DataUtils.save(savedCollapseList, this, "categorydata");
}
openAccessModal (channel, allowed) {
let isThread = BDFDB.ChannelUtils.isThread(channel);
let guild = BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id);
let myMember = guild && BDFDB.LibraryModules.MemberStore.getMember(guild.id, BDFDB.UserUtils.me.id);
let parentChannel = isThread && BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.ChannelStore.getChannel(channel.id).parent_id);
let category = parentChannel && parentChannel.parent_id && BDFDB.LibraryModules.ChannelStore.getChannel(parentChannel.parent_id) || BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.ChannelStore.getChannel(channel.id).parent_id);
let lightTheme = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
let addUser = (id, users) => {
let user = BDFDB.LibraryModules.UserStore.getUser(id);
if (user) users.push(Object.assign({}, user, BDFDB.LibraryModules.MemberStore.getMember(guild.id, id) || {}));
else users.push({id: id, username: `UserId: ${id}`, fetchable: true});
};
let checkAllowPerm = permString => {
return (permString | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == permString && (channel.type != BDFDB.DiscordConstants.ChannelTypes.GUILD_VOICE || (permString | BDFDB.DiscordConstants.Permissions.CONNECT) == permString);
};
let checkDenyPerm = permString => {
return (permString | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == permString || (channel.type == BDFDB.DiscordConstants.ChannelTypes.GUILD_VOICE && (permString | BDFDB.DiscordConstants.Permissions.CONNECT) == permString);
};
let allowedRoles = [], allowedUsers = [], deniedRoles = [], deniedUsers = [], everyoneDenied = false;
for (let id in channel.permissionOverwrites) {
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") && checkAllowPerm(channel.permissionOverwrites[id].allow)) {
allowedRoles.push(Object.assign({overwritten: myMember && myMember.roles.includes(id) && !allowed}, guild.roles[id]));
}
else if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER) && checkAllowPerm(channel.permissionOverwrites[id].allow)) {
addUser(id, allowedUsers);
}
if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.ROLE || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.ROLE) && checkDenyPerm(channel.permissionOverwrites[id].deny)) {
deniedRoles.push(guild.roles[id]);
if (guild.roles[id] && guild.roles[id].name == "@everyone") everyoneDenied = true;
}
else if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER) && checkDenyPerm(channel.permissionOverwrites[id].deny)) {
addUser(id, deniedUsers);
}
}
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]));
if (allowed && !everyoneDenied) allowedRoles.push({name: "@everyone"});
let allowedElements = [], deniedElements = [];
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}));
const infoStrings = [
isThread && {
title: BDFDB.LanguageUtils.LanguageStrings.THREAD_NAME,
text: channel.name
}, !isThread && {
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,
text: BDFDB.ReactUtils.markdownParse(channel.topic || "---")
}, {
title: BDFDB.LanguageUtils.LanguageStrings.CHANNEL_TYPE,
text: BDFDB.LanguageUtils.LanguageStrings[typeNameMap[BDFDB.DiscordConstants.ChannelTypes[channel.type]]]
}, isThread && parentChannel && {
title: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_CHANNEL_NAME,
text: parentChannel.name
}, {
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
})
})
]).flat(10).filter(n => n);
BDFDB.ModalUtils.open(this, {
size: "MEDIUM",
header: BDFDB.LanguageUtils.LanguageStrings.CHANNEL + " " + BDFDB.LanguageUtils.LanguageStrings.ACCESSIBILITY,
subHeader: "#" + channel.name,
className: BDFDB.disCN._showhiddenchannelsaccessmodal,
contentClassName: BDFDB.DOMUtils.formatClassName(!isThread && BDFDB.disCN.listscroller),
onOpen: modalInstance => {if (modalInstance) accessModal = modalInstance;},
children: isThread ? infoStrings : [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, {
className: BDFDB.disCN.modalsubinner,
tab: BDFDB.LanguageUtils.LanguageStrings.OVERLAY_SETTINGS_GENERAL_TAB,
children: infoStrings
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, {
tab: this.labels.modal_allowed,
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, {
tab: this.labels.modal_denied,
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"
})
})
]
});
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "bg": // Bulgarian
return {
context_changeorder: "Промяна на реда на скритите канали",
context_changeorder_bottom: "Родна категория в долната част",
context_changeorder_native: "Родна категория в правилен ред",
context_channelaccess: "Достъп до канал",
context_hidehidden: "Скриване на заключените канали",
modal_allowed: "Разрешено",
modal_denied: "Отрича се"
};
case "cs": // Czech
return {
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í",
context_channelaccess: "Přístup ke kanálu",
context_hidehidden: "Skrýt zamčené kanály",
modal_allowed: "Povoleno",
modal_denied: "Odepřeno"
};
case "da": // Danish
return {
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",
context_channelaccess: "Kanaltilgang",
context_hidehidden: "Skjul låste kanaler",
modal_allowed: "Tilladt",
modal_denied: "Nægtet"
};
case "de": // German
return {
context_changeorder: "Reihenfolge der versteckten Kanäle ändern",
context_changeorder_bottom: "Native Kategorie ganz unten",
context_changeorder_native: "Native Kategorie in der richtigen Reihenfolge",
context_channelaccess: "Kanalzugriff",
context_hidehidden: "Versteckte Kanäle ausblenden",
modal_allowed: "Erlaubt",
modal_denied: "Verweigert"
};
case "el": // Greek
return {
context_changeorder: "Αλλαγή σειράς κρυφών καναλιών",
context_changeorder_bottom: "Εγγενής κατηγορία στο κάτω μέρος",
context_changeorder_native: "Εγγενής κατηγορία σε σωστή σειρά",
context_channelaccess: "Πρόσβαση καναλιού",
context_hidehidden: "Απόκρυψη κλειδωμένων καναλιών",
modal_allowed: "Επιτρεπόμενο",
modal_denied: "Απορρίφθηκε"
};
case "es": // Spanish
return {
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",
context_channelaccess: "Acceso al canal",
context_hidehidden: "Ocultar canales bloqueados",
modal_allowed: "Permitido",
modal_denied: "Negado"
};
case "fi": // Finnish
return {
context_changeorder: "Muuta piilotettujen kanavien järjestystä",
context_changeorder_bottom: "Alkuperäinen luokka alareunassa",
context_changeorder_native: "Alkuperäinen luokka oikeassa järjestyksessä",
context_channelaccess: "Kanavan käyttöoikeus",
context_hidehidden: "Piilota lukitut kanavat",
modal_allowed: "Sallittu",
modal_denied: "Kielletty"
};
case "fr": // French
return {
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",
context_channelaccess: "Accès à la chaîne",
context_hidehidden: "Masquer les salons verrouillées",
modal_allowed: "Permis",
modal_denied: "Refusé"
};
case "hi": // Hindi
return {
context_changeorder: "हिडन चैनल ऑर्डर बदलें",
context_changeorder_bottom: "नीचे की ओर मूल श्रेणी",
context_changeorder_native: "मूल श्रेणी सही क्रम में",
context_channelaccess: "चैनल एक्सेस",
context_hidehidden: "बंद चैनल छुपाएं Hide",
modal_allowed: "अनुमति है",
modal_denied: "निषेध"
};
case "hr": // Croatian
return {
context_changeorder: "Promijenite redoslijed skrivenih kanala",
context_changeorder_bottom: "Izvorna kategorija na dnu",
context_changeorder_native: "Izvorna kategorija u ispravnom redoslijedu",
context_channelaccess: "Pristup kanalu",
context_hidehidden: "Sakrij zaključane kanale",
modal_allowed: "Dopuštena",
modal_denied: "Odbijen"
};
case "hu": // Hungarian
return {
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",
context_channelaccess: "Csatornához való hozzáférés",
context_hidehidden: "Zárt csatornák elrejtése",
modal_allowed: "Megengedett",
modal_denied: "Megtagadva"
};
case "it": // Italian
return {
context_changeorder: "Modifica l'ordine dei canali nascosti",
context_changeorder_bottom: "Categoria nativa in basso",
context_changeorder_native: "Categoria nativa nell'ordine corretto",
context_channelaccess: "Accesso al canale",
context_hidehidden: "Nascondi canali bloccati",
modal_allowed: "Consentito",
modal_denied: "Negato"
};
case "ja": // Japanese
return {
context_changeorder: "非表示チャネルの順序を変更する",
context_changeorder_bottom: "下部のネイティブカテゴリ",
context_changeorder_native: "正しい順序のネイティブカテゴリ",
context_channelaccess: "チャネルアクセス",
context_hidehidden: "ロックされたチャンネルを非表示にする",
modal_allowed: "許可",
modal_denied: "拒否されました"
};
case "ko": // Korean
return {
context_changeorder: "숨겨진 채널 순서 변경",
context_changeorder_bottom: "하단의 기본 카테고리",
context_changeorder_native: "올바른 순서의 네이티브 카테고리",
context_channelaccess: "채널 액세스",
context_hidehidden: "잠긴 채널 숨기기",
modal_allowed: "허용됨",
modal_denied: "거부 됨"
};
case "lt": // Lithuanian
return {
context_changeorder: "Keisti paslėptų kanalų tvarką",
context_changeorder_bottom: "Gimtoji kategorija apačioje",
context_changeorder_native: "Gimtoji kategorija teisinga tvarka",
context_channelaccess: "Prieiga prie kanalo",
context_hidehidden: "Slėpti užrakintus kanalus",
modal_allowed: "Leidžiama",
modal_denied: "Paneigta"
};
case "nl": // Dutch
return {
context_changeorder: "Wijzig de volgorde van verborgen kanalen",
context_changeorder_bottom: "Native categorie onderaan",
context_changeorder_native: "Native categorie in de juiste volgorde",
context_channelaccess: "Kanaaltoegang",
context_hidehidden: "Verberg vergrendelde kanalen",
modal_allowed: "Toegestaan",
modal_denied: "Geweigerd"
};
case "no": // Norwegian
return {
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",
context_channelaccess: "Kanaltilgang",
context_hidehidden: "Skjul låste kanaler",
modal_allowed: "Tillatt",
modal_denied: "Nektet"
};
case "pl": // Polish
return {
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",
context_channelaccess: "Dostęp do kanałów",
context_hidehidden: "Ukryj zablokowane kanały",
modal_allowed: "Dozwolony",
modal_denied: "Odmówiono"
};
case "pt-BR": // Portuguese (Brazil)
return {
context_changeorder: "Alterar a ordem dos canais ocultos",
context_changeorder_bottom: "Categoria nativa na parte inferior",
context_changeorder_native: "Categoria nativa na ordem correta",
context_channelaccess: "Acesso ao canal",
context_hidehidden: "Ocultar canais bloqueados",
modal_allowed: "Permitido",
modal_denied: "Negado"
};
case "ro": // Romanian
return {
context_changeorder: "Schimbați comanda canalelor ascunse",
context_changeorder_bottom: "Categorie nativă în partea de jos",
context_changeorder_native: "Categorie nativă în ordine corectă",
context_channelaccess: "Acces la canal",
context_hidehidden: "Ascundeți canalele blocate",
modal_allowed: "Permis",
modal_denied: "Negat"
};
case "ru": // Russian
return {
context_changeorder: "Изменить порядок скрытых каналов",
context_changeorder_bottom: "Родная категория внизу",
context_changeorder_native: "Собственная категория в правильном порядке",
context_channelaccess: "Доступ к каналу",
context_hidehidden: "Скрыть заблокированные каналы",
modal_allowed: "Разрешенный",
modal_denied: "Отказано"
};
case "sv": // Swedish
return {
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",
context_channelaccess: "Kanaltillgång",
context_hidehidden: "Dölj låsta kanaler",
modal_allowed: "Tillåtet",
modal_denied: "Förnekad"
};
case "th": // Thai
return {
context_changeorder: "เปลี่ยนลำดับช่องที่ซ่อนอยู่",
context_changeorder_bottom: "หมวดหมู่ดั้งเดิมที่ด้านล่าง",
context_changeorder_native: "หมวดหมู่ดั้งเดิมในลำดับที่ถูกต้อง",
context_channelaccess: "การเข้าถึงช่อง",
context_hidehidden: "ซ่อนช่องที่ถูกล็อก",
modal_allowed: "ได้รับอนุญาต",
modal_denied: "ถูกปฏิเสธ"
};
case "tr": // Turkish
return {
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",
context_channelaccess: "Kanal Erişimi",
context_hidehidden: "Kilitli Kanalları Gizle",
modal_allowed: "İzin veriliyor",
modal_denied: "Reddedildi"
};
case "uk": // Ukrainian
return {
context_changeorder: "Змінити порядок прихованих каналів",
context_changeorder_bottom: "Рідна категорія внизу",
context_changeorder_native: "Рідна категорія в правильному порядку",
context_channelaccess: "Доступ до каналу",
context_hidehidden: "Сховати заблоковані канали",
modal_allowed: "Дозволено",
modal_denied: "Заперечується"
};
case "vi": // Vietnamese
return {
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ự",
context_channelaccess: "Quyền truy cập kênh",
context_hidehidden: "Ẩn các kênh đã khóa",
modal_allowed: "Được phép",
modal_denied: "Phủ định"
};
case "zh-CN": // Chinese (China)
return {
context_changeorder: "更改隐藏频道顺序",
context_changeorder_bottom: "底部的原生类别",
context_changeorder_native: "正确顺序的本地类别",
context_channelaccess: "频道访问",
context_hidehidden: "隐藏锁定的频道",
modal_allowed: "允许的",
modal_denied: "被拒绝"
};
case "zh-TW": // Chinese (Taiwan)
return {
context_changeorder: "更改隱藏頻道順序",
context_changeorder_bottom: "底部的原生類別",
context_changeorder_native: "正確順序的本地類別",
context_channelaccess: "頻道訪問",
context_hidehidden: "隱藏鎖定的頻道",
modal_allowed: "允許的",
modal_denied: "被拒絕"
};
default: // English
return {
context_changeorder: "Change Hidden Channels Order",
context_changeorder_bottom: "Native Category at the bottom",
context_changeorder_native: "Native Category in correct Order",
context_channelaccess: "Channel Access",
context_hidehidden: "Hide Locked Channels",
modal_allowed: "Permitted",
modal_denied: "Denied"
};
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment