From 7c692758ee999cf664d691ef1fab1399aea2798b Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Sun, 28 Aug 2022 17:59:33 -0600 Subject: [PATCH] set process title --- src/commands/switchChannel.js | 5 ++++- src/commands/switchGuild.js | 6 +++++- src/index.js | 2 ++ src/lib/messages.js | 10 ++++++---- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/commands/switchChannel.js b/src/commands/switchChannel.js index 41bf69b..ded227f 100644 --- a/src/commands/switchChannel.js +++ b/src/commands/switchChannel.js @@ -6,7 +6,6 @@ const {listUsers} = require("./listUsers"); function switchChannel(input) { if (input == "") { listUsers(); - comcord.state.channelSwitch = false; return; } let target; @@ -29,6 +28,10 @@ function switchChannel(input) { comcord.state.lastChannel.set(comcord.state.currentGuild, target); listUsers(); + + const channel = guild.channels.get(comcord.state.currentChannel); + + process.title = `${guild.name} - ${channel.name} - comcord`; } } diff --git a/src/commands/switchGuild.js b/src/commands/switchGuild.js index 844a561..77b2243 100644 --- a/src/commands/switchGuild.js +++ b/src/commands/switchGuild.js @@ -32,7 +32,6 @@ function switchGuild(input) { console.log(""); } else { comcord.state.currentGuild = target; - // TODO: store last visited channel and switch to it if we've been to this guild before if (!comcord.state.lastChannel.has(target)) { const topChannel = findTopChannel(target); comcord.state.currentChannel = topChannel.id; @@ -43,6 +42,11 @@ function switchGuild(input) { listChannels(); listUsers(); + + const guild = comcord.client.guilds.get(comcord.state.currentGuild); + const channel = guild.channels.get(comcord.state.currentChannel); + + process.title = `${guild.name} - ${channel.name} - comcord`; } } diff --git a/src/index.js b/src/index.js index 1355832..9361e8f 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,8 @@ const chalk = require("chalk"); const token = process.argv[2]; +process.title = "comcord"; + global.comcord = { state: { currentGuild: null, diff --git a/src/lib/messages.js b/src/lib/messages.js index b19aa1f..3685522 100644 --- a/src/lib/messages.js +++ b/src/lib/messages.js @@ -17,12 +17,14 @@ function processMessage({ const headerLength = 5 + reply.author.username.length; const length = headerLength + reply.content.length; + const replyContent = reply.content.replace(/\n/g, " "); + if (noColor) { console.log( ` \u250d [${reply.author.username}] ${ length > 79 - ? reply.content.substring(0, length - headerLength) + "\u2026" - : reply.content + ? replyContent.substring(0, length - headerLength) + "\u2026" + : replyContent }` ); } else { @@ -32,8 +34,8 @@ function processMessage({ chalk.reset( `${ length > 79 - ? reply.content.substring(0, length - headerLength) + "\u2026" - : reply.content + ? replyContent.substring(0, length - headerLength) + "\u2026" + : replyContent }` ) );