private channel indicator for channel list

This commit is contained in:
Cynthia Foxwell 2022-08-27 22:06:26 -06:00
parent 0b1387f7b9
commit bc9bf22163

View file

@ -321,7 +321,11 @@ function listChannels() {
channels.sort((a, b) => a.position - b.position); channels.sort((a, b) => a.position - b.position);
for (const channel of channels) { for (const channel of channels) {
if (channel.name.length > longest) longest = channel.name.length; const perms = channel.permissionsOf(client.user.id);
const private = !perms.has(Eris.Constants.Permissions.readMessages);
if (channel.name.length + (private ? 1 : 0) > longest)
longest = channel.name.length + (private ? 1 : 0);
if (channel.topic != null && channel.topic.length > longestTopic) if (channel.topic != null && channel.topic.length > longestTopic)
longestTopic = channel.topic.length; longestTopic = channel.topic.length;
} }
@ -337,9 +341,12 @@ function listChannels() {
for (const channel of channels) { for (const channel of channels) {
const topic = const topic =
channel.topic != null ? channel.topic.replace(/\n/g, " ") : ""; channel.topic != null ? channel.topic.replace(/\n/g, " ") : "";
const perms = channel.permissionsOf(client.user.id);
const private = !perms.has(Eris.Constants.Permissions.readMessages);
console.log( console.log(
" " + " " +
channel.name.padStart(longest, " ") + ((private ? "*" : "") + channel.name).padStart(longest, " ") +
" " + " " +
(topic.length > 80 - longest + 9 (topic.length > 80 - longest + 9
? topic.substring(0, 79 - (longest + 5)) + "\u2026" ? topic.substring(0, 79 - (longest + 5)) + "\u2026"