diff --git a/commands.js b/commands.js index b862c60..93e48dd 100644 --- a/commands.js +++ b/commands.js @@ -54,14 +54,18 @@ function markServerBufferUnread(app) { } const join = { - usage: "", + usage: " [password]", description: "Join a channel", execute: (app, args) => { let channel = args[0]; if (!channel) { throw new Error("Missing channel name"); } - app.open(channel); + if (args.length > 1) { + app.open(channel, null, args[1]); + } else { + app.open(channel); + } }, }; diff --git a/components/app.js b/components/app.js index 55d4087..eb5ed90 100644 --- a/components/app.js +++ b/components/app.js @@ -1122,7 +1122,7 @@ export default class App extends Component { client.monitor(target); } - open(target, serverID) { + open(target, serverID, password) { if (!serverID) { serverID = State.getActiveServerID(this.state); } @@ -1132,7 +1132,7 @@ export default class App extends Component { this.switchBuffer({ server: serverID }); } else if (client.isChannel(target)) { this.switchToChannel = target; - client.join(target).catch((err) => { + client.join(target, password).catch((err) => { this.showError(err); }); } else { diff --git a/lib/client.js b/lib/client.js index 792cac7..1bb62e4 100644 --- a/lib/client.js +++ b/lib/client.js @@ -802,10 +802,14 @@ export default class Client extends EventTarget { }); } - join(channel) { + join(channel, password) { + let params = [channel]; + if (password) { + params.push(password); + } let msg = { command: "JOIN", - params: [channel], + params: params, }; return this.roundtrip(msg, (msg) => { switch (msg.command) {