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
1 changed files with 9 additions and 2 deletions

View File

@ -321,7 +321,11 @@ function listChannels() {
channels.sort((a, b) => a.position - b.position);
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)
longestTopic = channel.topic.length;
}
@ -337,9 +341,12 @@ function listChannels() {
for (const channel of channels) {
const topic =
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(
" " +
channel.name.padStart(longest, " ") +
((private ? "*" : "") + channel.name).padStart(longest, " ") +
" " +
(topic.length > 80 - longest + 9
? topic.substring(0, 79 - (longest + 5)) + "\u2026"