-
-
Notifications
You must be signed in to change notification settings - Fork 389
/
ShowHiddenChannels.plugin.js
2003 lines (1749 loc) · 79.4 KB
/
ShowHiddenChannels.plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @name ShowHiddenChannels
* @displayName Show Hidden Channels (SHC)
* @version 0.5.6
* @author JustOptimize (Oggetto)
* @authorId 619203349954166804
* @source https://github.com/JustOptimize/ShowHiddenChannels
* @description A plugin which displays all hidden Channels and allows users to view information about them, this won't allow you to read them (impossible).
*/
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/components/AdminRolesComponent.jsx":
/*!************************************************!*\
!*** ./src/components/AdminRolesComponent.jsx ***!
\************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
const {
TextElement,
RolePill,
DiscordConstants
} = (__webpack_require__(/*! ../utils/modules */ "./src/utils/modules.js").ModuleStore);
const React = BdApi.React;
const AdminRolesElement = ({
guild,
settings,
roles
}) => {
if (!settings['showAdmin']) return null;
if (settings['showAdmin'] == 'channel') return null;
const adminRoles = [];
Object.values(roles).forEach(role => {
if ((role.permissions & BigInt(8)) == BigInt(8) && (settings['showAdmin'] == 'include' || settings['showAdmin'] == 'exclude' && !role.tags?.bot_id)) {
adminRoles.push(role);
}
});
if (!adminRoles?.length) {
return null;
}
return BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
style: {
borderTop: '1px solid var(--background-tertiary)',
padding: 5
}
}, "Admin roles:", BdApi.React.createElement("div", {
style: {
paddingTop: 5
}
}, adminRoles.map(m => BdApi.React.createElement(RolePill, {
key: m.id,
canRemove: false,
className: `shc-rolePill`,
disableBorderColor: true,
guildId: guild.id,
onRemove: DiscordConstants.NOOP,
role: m
}))));
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (React.memo(AdminRolesElement));
/***/ }),
/***/ "./src/components/ChannelRolesComponent.jsx":
/*!**************************************************!*\
!*** ./src/components/ChannelRolesComponent.jsx ***!
\**************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ ChannelRolesComponent)
/* harmony export */ });
const {
TextElement,
RolePill,
DiscordConstants
} = (__webpack_require__(/*! ../utils/modules */ "./src/utils/modules.js").ModuleStore);
function ChannelRolesComponent({
channel,
guild,
settings,
roles
}) {
const channelRoles = Object.values(channel.permissionOverwrites).filter(role => role !== undefined && role?.type == 0 && (
//* 1024n = VIEW_CHANNEL permission
//* 8n = ADMINISTRATOR permission
//* If role is ADMINISTRATOR it can view channel even if overwrites deny VIEW_CHANNEL
settings.showAdmin && (roles[role.id].permissions & BigInt(8)) == BigInt(8) ||
//* If overwrites allow VIEW_CHANNEL (it will override the default role permissions)
(role.allow & BigInt(1024)) == BigInt(1024) ||
//* If role can view channel by default and overwrites don't deny VIEW_CHANNEL
roles[role.id].permissions & BigInt(1024) && (role.deny & BigInt(1024)) == 0));
return BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
style: {
borderTop: '1px solid var(--background-tertiary)',
padding: 8
}
}, "Channel-specific roles:", BdApi.React.createElement("div", {
style: {
paddingTop: 8
}
}, !channelRoles?.length && BdApi.React.createElement("span", null, "None"), channelRoles?.length > 0 && channelRoles.map(m => BdApi.React.createElement(RolePill, {
key: m.id,
canRemove: false,
className: `shc-rolePill`,
disableBorderColor: true,
guildId: guild.id,
onRemove: DiscordConstants.NOOP,
role: roles[m.id]
}))));
}
/***/ }),
/***/ "./src/components/ForumComponent.jsx":
/*!*******************************************!*\
!*** ./src/components/ForumComponent.jsx ***!
\*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ ForumComponent)
/* harmony export */ });
const TextElement = global.ZeresPluginLibrary?.DiscordModules?.TextElement;
function ForumComponent({
channel
}) {
if (channel.type != 15) return null;
if (!channel.availableTags && !channel.topic) {
return null;
}
return BdApi.React.createElement(TextElement, {
color: TextElement.Colors.HEADER_SECONDARY,
size: TextElement.Sizes.SIZE_24,
style: {
margin: '16px auto',
backgroundColor: 'var(--background-secondary)',
padding: 24,
borderRadius: 8,
color: 'var(--text-normal)',
fontWeight: 'bold',
maxWidth: '40vw'
}
}, "Forum", BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
size: TextElement.Sizes.SIZE_14,
style: {
marginTop: 24
}
}, channel.availableTags && channel.availableTags.length > 0 ? 'Tags: ' + channel.availableTags.map(tag => tag.name).join(', ') : 'Tags: No tags avaiable'), channel.topic && BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
size: TextElement.Sizes.SIZE_14,
style: {
marginTop: 16
}
}, "Guidelines: ", channel.topic), !channel.topic && BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
size: TextElement.Sizes.SIZE_14,
style: {
marginTop: 8
}
}, "Guidelines: No guidelines avaiable"));
}
/***/ }),
/***/ "./src/components/HiddenChannelIcon.jsx":
/*!**********************************************!*\
!*** ./src/components/HiddenChannelIcon.jsx ***!
\**********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ HiddenChannelIcon: () => (/* binding */ HiddenChannelIcon)
/* harmony export */ });
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
const Tooltip = BdApi.Components.Tooltip;
const React = BdApi.React;
function HiddenChannelComponent({
icon,
iconItem,
actionIcon
}) {
return BdApi.React.createElement(Tooltip, {
text: "Hidden Channel"
}, props => BdApi.React.createElement("div", _extends({
className: iconItem,
style: {
display: 'block'
}
}, props), icon == 'lock' && BdApi.React.createElement("svg", {
className: actionIcon,
viewBox: "0 0 24 24"
}, BdApi.React.createElement("path", {
fill: "currentColor",
d: "M17 11V7C17 4.243 14.756 2 12 2C9.242 2 7 4.243 7 7V11C5.897 11 5 11.896 5 13V20C5 21.103 5.897 22 7 22H17C18.103 22 19 21.103 19 20V13C19 11.896 18.103 11 17 11ZM12 18C11.172 18 10.5 17.328 10.5 16.5C10.5 15.672 11.172 15 12 15C12.828 15 13.5 15.672 13.5 16.5C13.5 17.328 12.828 18 12 18ZM15 11H9V7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V11Z"
})), icon == 'eye' && BdApi.React.createElement("svg", {
className: actionIcon,
viewBox: "0 0 24 24"
}, BdApi.React.createElement("path", {
fill: "currentColor",
d: "M12 5C5.648 5 1 12 1 12C1 12 5.648 19 12 19C18.352 19 23 12 23 12C23 12 18.352 5 12 5ZM12 16C9.791 16 8 14.21 8 12C8 9.79 9.791 8 12 8C14.209 8 16 9.79 16 12C16 14.21 14.209 16 12 16Z"
}), BdApi.React.createElement("path", {
fill: "currentColor",
d: "M12 14C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10C10.8954 10 10 10.8954 10 12C10 13.1046 10.8954 14 12 14Z"
}), BdApi.React.createElement("polygon", {
fill: "currentColor",
points: "22.6,2.7 22.6,2.8 19.3,6.1 16,9.3 16,9.4 15,10.4 15,10.4 10.3,15 2.8,22.5 1.4,21.1 21.2,1.3 "
}))));
}
const HiddenChannelIcon = React.memo(HiddenChannelComponent);
/***/ }),
/***/ "./src/components/IconSwitchWrapper.jsx":
/*!**********************************************!*\
!*** ./src/components/IconSwitchWrapper.jsx ***!
\**********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ IconSwitchWrapper: () => (/* binding */ IconSwitchWrapper)
/* harmony export */ });
const React = BdApi.React;
function IconSwitchWrapper({
icon,
value,
onChange,
children,
note
}) {
const [enabled, setEnabled] = React.useState(value);
return BdApi.React.createElement("div", null, BdApi.React.createElement("div", {
style: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
marginBottom: '16px',
marginTop: '16px'
}
}, BdApi.React.createElement("img", {
src: icon,
width: 48,
height: 48,
title: "Click to toggle",
style: {
borderRadius: '360px',
cursor: 'pointer',
border: enabled ? '3px solid green' : '3px solid grey',
marginRight: '8px'
},
onClick: () => {
onChange(!enabled);
setEnabled(!enabled);
}
}), BdApi.React.createElement("div", {
style: {
maxWidth: '89%'
}
}, BdApi.React.createElement("div", {
style: {
fontSize: '20px',
color: 'var(--header-primary)',
fontWeight: '600'
}
}, children), BdApi.React.createElement("div", {
style: {
color: 'var(--header-secondary)',
fontSize: '16px'
}
}, note))));
}
/***/ }),
/***/ "./src/components/Lockscreen.jsx":
/*!***************************************!*\
!*** ./src/components/Lockscreen.jsx ***!
\***************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Lockscreen: () => (/* binding */ Lockscreen)
/* harmony export */ });
/* harmony import */ var _UserMentionsComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./UserMentionsComponent */ "./src/components/UserMentionsComponent.jsx");
/* harmony import */ var _ChannelRolesComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ChannelRolesComponent */ "./src/components/ChannelRolesComponent.jsx");
/* harmony import */ var _AdminRolesComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./AdminRolesComponent */ "./src/components/AdminRolesComponent.jsx");
/* harmony import */ var _ForumComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ForumComponent */ "./src/components/ForumComponent.jsx");
/* harmony import */ var _utils_date__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/date */ "./src/utils/date.js");
const React = BdApi.React;
const {
TextElement,
GuildStore,
ChannelUtils
} = (__webpack_require__(/*! ../utils/modules */ "./src/utils/modules.js").ModuleStore);
const CHANNEL_TYPES = {
0: 'text',
2: 'voice',
4: 'category',
5: 'news',
6: 'store',
13: 'stage'
};
const Lockscreen = React.memo(({
chat,
channel,
settings
}) => {
const guild = GuildStore.getGuild(channel.guild_id);
const guildRoles = GuildStore.getRoles(guild.id);
return BdApi.React.createElement("div", {
className: ['shc-hidden-chat-content', chat].filter(Boolean).join(' '),
style: {
justifyContent: 'center',
alignItems: 'center'
}
}, BdApi.React.createElement("div", {
className: "shc-hidden-notice"
}, BdApi.React.createElement("img", {
style: {
WebkitUserDrag: 'none',
maxHeight: 128,
margin: '0 auto'
},
src: settings['hiddenChannelIcon'] == 'eye' ? 'https://raw.githubusercontent.com/JustOptimize/ShowHiddenChannels/main/assets/eye.png' : '/assets/755d4654e19c105c3cd108610b78d01c.svg'
}), BdApi.React.createElement(TextElement, {
color: TextElement.Colors.HEADER_PRIMARY,
size: TextElement.Sizes.SIZE_32,
style: {
marginTop: 20,
fontWeight: 'bold'
}
}, `This is a hidden ${CHANNEL_TYPES[channel.type] ?? 'unknown'} channel`), BdApi.React.createElement(TextElement, {
color: TextElement.Colors.HEADER_SECONDARY,
size: TextElement.Sizes.SIZE_16,
style: {
marginTop: 8
}
}, "You cannot see the contents of this channel. ", channel.topic && channel.type != 15 && 'However, you may see its topic.'), channel.topic && channel.type != 15 && (ChannelUtils?.renderTopic(channel, guild) || "ChannelUtils module is missing, topic won't be shown."), channel?.iconEmoji && BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
size: TextElement.Sizes.SIZE_14,
style: {
marginTop: 16
}
}, "Icon emoji: ", channel.iconEmoji.name ?? channel.iconEmoji.id), channel.rateLimitPerUser > 0 && BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
size: TextElement.Sizes.SIZE_14
}, "Slowmode: ", (0,_utils_date__WEBPACK_IMPORTED_MODULE_4__.convertToHMS)(channel.rateLimitPerUser)), channel.nsfw && BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
size: TextElement.Sizes.SIZE_14
}, "Age-Restricted Channel (NSFW) \uD83D\uDD1E"), channel.bitrate && channel.type == 2 && BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
size: TextElement.Sizes.SIZE_14
}, "Bitrate: ", channel.bitrate / 1000, "kbps"), BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
size: TextElement.Sizes.SIZE_14,
style: {
marginTop: 8
}
}, "Created on: ", (0,_utils_date__WEBPACK_IMPORTED_MODULE_4__.getDateFromSnowflake)(channel.id)), channel.lastMessageId && BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
size: TextElement.Sizes.SIZE_14
}, "Last message sent: ", (0,_utils_date__WEBPACK_IMPORTED_MODULE_4__.getDateFromSnowflake)(channel.lastMessageId)), settings['showPerms'] && channel.permissionOverwrites && BdApi.React.createElement("div", {
style: {
margin: '16px auto 0 auto',
backgroundColor: 'var(--background-secondary)',
padding: 10,
borderRadius: 5,
color: 'var(--text-normal)'
}
}, BdApi.React.createElement(_UserMentionsComponent__WEBPACK_IMPORTED_MODULE_0__["default"], {
channel: channel,
guild: guild,
settings: settings
}), BdApi.React.createElement(_ChannelRolesComponent__WEBPACK_IMPORTED_MODULE_1__["default"], {
channel: channel,
guild: guild,
settings: settings,
roles: guildRoles
}), BdApi.React.createElement(_AdminRolesComponent__WEBPACK_IMPORTED_MODULE_2__["default"], {
guild: guild,
settings: settings,
roles: guildRoles
})), BdApi.React.createElement(_ForumComponent__WEBPACK_IMPORTED_MODULE_3__["default"], {
channel: channel
})));
});
/***/ }),
/***/ "./src/components/UserMentionsComponent.jsx":
/*!**************************************************!*\
!*** ./src/components/UserMentionsComponent.jsx ***!
\**************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ UserMentionsComponent)
/* harmony export */ });
const React = BdApi.React;
const {
TextElement,
UserMentions,
ProfileActions,
GuildMemberStore,
UserStore,
DiscordConstants,
PermissionUtils
} = (__webpack_require__(/*! ../utils/modules */ "./src/utils/modules.js").ModuleStore);
function UserMentionsComponent({
channel,
guild,
settings
}) {
const [userMentionComponents, setUserMentionComponents] = React.useState([]);
const fetchMemberAndMap = async () => {
setUserMentionComponents('Loading...');
if (!settings.showPerms) {
return setUserMentionComponents(['None']);
}
const allUserOverwrites = Object.values(channel.permissionOverwrites).filter(user => Boolean(user && user?.type === 1));
for (const user of allUserOverwrites) {
if (UserStore.getUser(user.id)) continue;
await ProfileActions.fetchProfile(user.id, {
guildId: guild.id,
withMutualGuilds: false
});
if (allUserOverwrites.indexOf(user) !== allUserOverwrites.length - 1) {
// Wait between 500ms and 2000ms
await new Promise(resolve => setTimeout(resolve, Math.floor(Math.random() * 1500) + 500));
}
}
const filteredUserOverwrites = Object.values(channel.permissionOverwrites).filter(user => Boolean(PermissionUtils.can({
permission: DiscordConstants.Permissions.VIEW_CHANNEL,
user: UserStore.getUser(user.id),
context: channel
}) && GuildMemberStore.isMember(guild.id, user.id)));
if (!filteredUserOverwrites?.length) {
return setUserMentionComponents(['None']);
}
const mentionArray = filteredUserOverwrites.map(m => UserMentions.react({
userId: m.id,
channelId: channel.id
}, () => null, {
noStyleAndInteraction: false
}));
return setUserMentionComponents(mentionArray);
};
React.useEffect(() => {
fetchMemberAndMap();
}, [channel.id, guild.id, settings.showPerms, channel.permissionOverwrites]);
return BdApi.React.createElement(TextElement, {
color: TextElement.Colors.INTERACTIVE_NORMAL,
size: TextElement.Sizes.SIZE_14
}, "Users that can see this channel:", BdApi.React.createElement("div", {
style: {
marginTop: 8,
marginBottom: 8,
display: 'flex',
flexDirection: 'column',
flexWrap: 'wrap',
gap: 8,
padding: 8,
paddingTop: 0
}
}, userMentionComponents));
}
/***/ }),
/***/ "./src/styles.css":
/*!************************!*\
!*** ./src/styles.css ***!
\************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (".shc-hidden-notice {\n display: flex;\n flex-direction: column;\n text-align: center;\n overflow-y: auto;\n padding: 10dvh 0px;\n margin: 0px auto;\n width: 100%;\n}\n\n.shc-hidden-notice > div[class^='divider'] {\n display: none;\n}\n\n.shc-hidden-notice > div[class^='topic'] {\n background-color: var(--background-secondary);\n padding: 5px;\n max-width: 50dvh;\n text-overflow: ellipsis;\n border-radius: 8px;\n margin: 12px auto 0 auto;\n overflow: visible;\n}\n\n.shc-rolePill {\n background-color: var(--background-primary);\n padding: 12px;\n margin: 4px 0;\n}\n");
/***/ }),
/***/ "./src/utils/date.js":
/*!***************************!*\
!*** ./src/utils/date.js ***!
\***************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ convertToHMS: () => (/* binding */ convertToHMS),
/* harmony export */ getDateFromSnowflake: () => (/* binding */ getDateFromSnowflake)
/* harmony export */ });
const { Logger, LocaleManager } = (__webpack_require__(/*! ./modules */ "./src/utils/modules.js").ModuleStore);
function convertToHMS(timeInSeconds) {
timeInSeconds = Number(timeInSeconds);
const hours = Math.floor(timeInSeconds / 3600);
const minutes = Math.floor((timeInSeconds % 3600) / 60);
const seconds = Math.floor((timeInSeconds % 3600) % 60);
const formatTime = (value, unit) => (value > 0 ? `${value} ${unit}${value > 1 ? 's' : ''}` : '');
return [formatTime(hours, 'hour'), formatTime(minutes, 'minute'), formatTime(seconds, 'second')].join(' ');
}
function getDateFromSnowflake(snowflake) {
try {
const DISCORD_EPOCH = 1420070400000n;
const id = BigInt(snowflake);
const unix = (id >> 22n) + DISCORD_EPOCH;
return new Date(Number(unix)).toLocaleString(LocaleManager._chosenLocale);
} catch (err) {
Logger.err(err);
return '(Failed to get date)';
}
}
/***/ }),
/***/ "./src/utils/modules.js":
/*!******************************!*\
!*** ./src/utils/modules.js ***!
\******************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ ModuleStore: () => (/* binding */ ModuleStore),
/* harmony export */ loaded_successfully: () => (/* binding */ loaded_successfully)
/* harmony export */ });
const FallbackLibrary = {
Logger: {
info: console.info,
warn: console.warn,
err: console.error,
},
Settings: {},
DiscordModules: {},
};
const {
WebpackModules,
Utilities,
DOMTools,
Logger,
ReactTools,
Modals,
Settings: { SettingField, SettingPanel, SettingGroup, Switch, RadioGroup },
DiscordModules: {
ChannelStore,
MessageActions,
TextElement,
React,
ReactDOM,
GuildChannelsStore,
GuildMemberStore,
NavigationUtils,
ImageResolver,
UserStore,
Dispatcher,
DiscordPermissions,
},
} = global.ZeresPluginLibrary ?? FallbackLibrary;
let key = null;
let loaded_successfully_internal = true;
const Tooltip = window.BdApi?.Components?.Tooltip;
const ContextMenu = window.BdApi?.ContextMenu;
const Utils = window.BdApi?.Utils;
const BetterWebpackModules = window.BdApi.Webpack;
const GuildStore = WebpackModules?.getByProps('getGuild', 'getGuildCount', 'getGuildIds', 'getGuilds', 'isLoaded');
const LocaleManager = WebpackModules?.getByProps('setLocale');
const DiscordConstants = {};
DiscordConstants.Permissions = DiscordPermissions;
DiscordConstants.ChannelTypes = Object.values(
WebpackModules?.getModule(
(m) =>
m &&
typeof m === 'object' &&
!Array.isArray(m) &&
Object.values(m).some((v) => v?.ADMINISTRATOR) &&
Object.values(m).some((v) => v?.GUILD_VOICE)
)
).find((c) => c.GUILD_VOICE);
DiscordConstants.NOOP = () => {};
if (!DiscordConstants.Permissions || !DiscordConstants.ChannelTypes || !DiscordConstants.NOOP) {
loaded_successfully_internal = false;
console.error('Failed to load DiscordConstants', DiscordConstants);
}
const chat = WebpackModules?.getByProps('chat', 'chatContent')?.chat;
const Route = WebpackModules.getModule((m) => /.ImpressionTypes.PAGE,name:\w+,/.test(m?.Z?.toString()));
const ChannelItem = WebpackModules.getModule(
(m) =>
m &&
typeof m === 'object' &&
Object.values(m).some((c) => c && typeof c === 'function' && c?.toString?.()?.includes('.iconContainerWithGuildIcon,'))
);
const ChannelItemKey = Object.keys(ChannelItem).find((k) => {
return ChannelItem[k]?.toString()?.includes('.ALL_MESSAGES');
});
const ChannelItemUtils = WebpackModules?.getModule(
(m) =>
m &&
typeof m === 'object' &&
Object.keys(m).some((k) => m[k] && typeof m[k] === 'function' && m[k]?.toString()?.includes('["/7EhaW"]') || m[k]?.toString()?.includes('.Messages.CHANNEL_TOOLTIP_RULES'))
);
const ChannelItemUtilsKey = Object.keys(ChannelItemUtils || {}).find((k) => {
return ChannelItemUtils[k]?.toString()?.includes('.AnnouncementsWarningIcon');
});
const RolePill = WebpackModules?.getModule(
(m) =>
m &&
typeof m === 'object' &&
Object.values(m).some((c) => c && typeof c === 'function' && c?.toString()?.includes('.u3RVsL') || c?.toString()?.includes('.Messages.USER_PROFILE_REMOVE_ROLE'))
);
const ChannelPermissionStore = WebpackModules?.getByProps('getChannelPermissions');
if (!ChannelPermissionStore?.can) {
loaded_successfully_internal = false;
console.error('Failed to load ChannelPermissionStore', ChannelPermissionStore);
}
const PermissionStoreActionHandler = Utils?.findInTree(
Dispatcher,
(c) => c?.name === 'PermissionStore' && typeof c?.actionHandler?.CONNECTION_OPEN === 'function'
)?.actionHandler;
const ChannelListStoreActionHandler = Utils?.findInTree(
Dispatcher,
(c) => c?.name === 'ChannelListStore' && typeof c?.actionHandler?.CONNECTION_OPEN === 'function'
)?.actionHandler;
const container = WebpackModules?.getByProps('container', 'hubContainer')?.container;
// const Channel = WebpackModules?.getByProps('ChannelRecordBase')?.ChannelRecordBase;
const ChannelRecordBase = WebpackModules?.getModule((m) => m?.Sf?.prototype?.isManaged)?.Sf;
const ChannelListStore = BetterWebpackModules.getStore("ChannelListStore");
const DEFAULT_AVATARS = WebpackModules?.getByProps('DEFAULT_AVATARS')?.DEFAULT_AVATARS;
const Icon = WebpackModules?.getByProps('iconItem');
const [iconItem, actionIcon] = [Icon?.iconItem, Icon?.actionIcon];
const ReadStateStore = BetterWebpackModules.getStore('ReadStateStore');
const Voice = WebpackModules?.getByProps('getVoiceStateStats');
const UserMentions = WebpackModules?.getByProps('handleUserContextMenu');
const ChannelUtils = {
renderTopic: WebpackModules?.getModule(
(m) =>
m &&
typeof m === 'object' &&
Object.keys(m).find((k) => {
key = k;
return m[k] && typeof m[k] === 'function' && m[k]?.toString()?.includes('.GROUP_DM:return null');
})
)?.[key],
};
if (!ChannelUtils.renderTopic) {
loaded_successfully_internal = false;
console.error('Failed to load ChannelUtils', ChannelUtils);
}
const ProfileActions = {
fetchProfile: WebpackModules?.getModule(
(m) =>
m &&
typeof m === 'object' &&
Object.keys(m).find((k) => {
key = k;
return m[k] && typeof m[k] === 'function' && m[k]?.toString()?.includes('USER_PROFILE_FETCH_START');
})
)?.[key],
};
if (!ProfileActions.fetchProfile) {
loaded_successfully_internal = false;
console.error('Failed to load ProfileActions', ProfileActions);
}
const PermissionUtilsModule = WebpackModules?.getModule((m) =>
Object.values(m).some((c) => c && typeof c === 'function' && c?.toString()?.includes('.computeLurkerPermissionsAllowList()'))
);
Object.keys(PermissionUtilsModule).find((k) => {
key = k;
return PermissionUtilsModule[k]?.toString()?.includes('excludeGuildPermissions:');
});
const PermissionUtils = {
can: PermissionUtilsModule?.[key],
};
const CategoryStore = WebpackModules?.getByProps('isCollapsed', 'getCollapsedCategories');
const UsedModules = {
/* Library */
Utilities,
DOMTools,
Logger,
ReactTools,
Modals,
/* Settings */
SettingField,
SettingPanel,
SettingGroup,
Switch,
RadioGroup,
/* Discord Modules (From lib) */
ChannelStore,
MessageActions,
TextElement,
React,
ReactDOM,
GuildChannelsStore,
GuildMemberStore,
LocaleManager,
NavigationUtils,
ImageResolver,
UserStore,
Dispatcher,
/* BdApi */
Tooltip,
ContextMenu,
Utils,
/* Manually found modules */
GuildStore,
DiscordConstants,
chat,
Route,
ChannelItem,
ChannelItemKey,
ChannelItemUtils,
ChannelItemUtilsKey,
ChannelPermissionStore,
PermissionStoreActionHandler,
ChannelListStoreActionHandler,
container,
ChannelRecordBase,
ChannelListStore,
DEFAULT_AVATARS,
iconItem,
actionIcon,
ReadStateStore,
Voice,
RolePill,
UserMentions,
ChannelUtils,
ProfileActions,
PermissionUtils,
CategoryStore,
};
function checkVariables() {
if (!global.ZeresPluginLibrary) {
Logger.err('ZeresPluginLibrary not found.');
return false;
}
for (const variable in UsedModules) {
if (!UsedModules[variable]) {
Logger.err(`Variable not found: ${variable}`);
}
}
if (!loaded_successfully_internal) {
Logger.err('Failed to load internal modules.');
return false;
}
if (Object.values(UsedModules).includes(undefined)) {
return false;
}
Logger.info('All variables found.');
return true;
}
const loaded_successfully = checkVariables();
const ModuleStore = UsedModules;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _styles_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./styles.css */ "./src/styles.css");
const config = {
info: {
name: 'ShowHiddenChannels',
authors: [
{
name: 'JustOptimize (Oggetto)',
},
],
description:
"A plugin which displays all hidden Channels and allows users to view information about them, this won't allow you to read them (impossible).",
version: "0.5.6",
github: 'https://github.com/JustOptimize/ShowHiddenChannels',
},
changelog: [
{
title: 'v0.5.6 - Fix Missing Module (LocaleManager)',
items: [
'Fixed missing LocaleManager module.',
],
},
{
title: 'v0.5.5 - Fix Crash',
items: [
'Fix Crash when using canary/ptb version of Discord. (#218)',
],
},
{
title: 'v0.5.4 - Fix Crash',
items: [
'Fix Crash when muting/unmuting specific servers. (#214)',
],
},
],
main: 'ShowHiddenChannels.plugin.js',
github_short: 'JustOptimize/ShowHiddenChannels',
};
class MissingZeresDummy {
constructor() {
console.warn(
'ZeresPluginLibrary is required for this plugin to work. Please install it from https://betterdiscord.app/Download?id=9'
);
this.downloadZLibPopup();
}
start() { }
stop() { }
getDescription() {
return `The library plugin needed for ${config.info.name} is missing. Please enable this plugin, click the settings icon on the right and click "Download Now" to install it.`;
}
getSettingsPanel() {
// Close Settings Panel and show modal to download ZLib
const buttonClicker = document.createElement('oggetto');
buttonClicker.addEventListener('DOMNodeInserted', () => {
// Hide Settings Panel to prevent it from showing up before the modal
buttonClicker.parentElement.parentElement.parentElement.style.display = 'none';
// Close Settings Panel
const buttonToClick = document.querySelector('.bd-button > div');
buttonToClick.click();
// Show modal to download ZLib
this.downloadZLibPopup();
});
return buttonClicker;
}
async downloadZLib() {
window.BdApi.UI.showToast('Downloading ZeresPluginLibrary...', {
type: 'info',
});
// TODO: Use BdApi.Net.fetch
eval('require')('request').get('https://betterdiscord.app/gh-redirect?id=9', async (err, resp, body) => {
if (err || !body) return this.downloadZLibErrorPopup();
if (!body.match(/(?<=version: ").*(?=")/)) {
console.error('Failed to download ZeresPluginLibrary, this is not the correct content.');
return this.downloadZLibErrorPopup();
}
await this.manageFile(body);
});
}
manageFile(content) {
this.downloadSuccessfulToast();
new Promise((cb) => {
eval('require')('fs').writeFile(
eval('require')('path').join(window.BdApi.Plugins.folder, '0PluginLibrary.plugin.js'),
content,
cb
);
});
}
downloadSuccessfulToast() {
window.BdApi.UI.showToast('Successfully downloaded ZeresPluginLibrary!', {
type: 'success',
});
}