set process title

This commit is contained in:
Cynthia Foxwell 2022-08-28 17:59:33 -06:00
parent bf1a94bc19
commit 7c692758ee
4 changed files with 17 additions and 6 deletions

View File

@ -6,7 +6,6 @@ const {listUsers} = require("./listUsers");
function switchChannel(input) { function switchChannel(input) {
if (input == "") { if (input == "") {
listUsers(); listUsers();
comcord.state.channelSwitch = false;
return; return;
} }
let target; let target;
@ -29,6 +28,10 @@ function switchChannel(input) {
comcord.state.lastChannel.set(comcord.state.currentGuild, target); comcord.state.lastChannel.set(comcord.state.currentGuild, target);
listUsers(); listUsers();
const channel = guild.channels.get(comcord.state.currentChannel);
process.title = `${guild.name} - ${channel.name} - comcord`;
} }
} }

View File

@ -32,7 +32,6 @@ function switchGuild(input) {
console.log("<guild not found>"); console.log("<guild not found>");
} else { } else {
comcord.state.currentGuild = target; 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)) { if (!comcord.state.lastChannel.has(target)) {
const topChannel = findTopChannel(target); const topChannel = findTopChannel(target);
comcord.state.currentChannel = topChannel.id; comcord.state.currentChannel = topChannel.id;
@ -43,6 +42,11 @@ function switchGuild(input) {
listChannels(); listChannels();
listUsers(); 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`;
} }
} }

View File

@ -3,6 +3,8 @@ const chalk = require("chalk");
const token = process.argv[2]; const token = process.argv[2];
process.title = "comcord";
global.comcord = { global.comcord = {
state: { state: {
currentGuild: null, currentGuild: null,

View File

@ -17,12 +17,14 @@ function processMessage({
const headerLength = 5 + reply.author.username.length; const headerLength = 5 + reply.author.username.length;
const length = headerLength + reply.content.length; const length = headerLength + reply.content.length;
const replyContent = reply.content.replace(/\n/g, " ");
if (noColor) { if (noColor) {
console.log( console.log(
` \u250d [${reply.author.username}] ${ ` \u250d [${reply.author.username}] ${
length > 79 length > 79
? reply.content.substring(0, length - headerLength) + "\u2026" ? replyContent.substring(0, length - headerLength) + "\u2026"
: reply.content : replyContent
}` }`
); );
} else { } else {
@ -32,8 +34,8 @@ function processMessage({
chalk.reset( chalk.reset(
`${ `${
length > 79 length > 79
? reply.content.substring(0, length - headerLength) + "\u2026" ? replyContent.substring(0, length - headerLength) + "\u2026"
: reply.content : replyContent
}` }`
) )
); );