PrivateMessage: add recipient property

parent 850af022
......@@ -634,7 +634,7 @@ declare module "bancho.js" {
* The type for private messages.
*/
class PrivateMessage extends BanchoMessage {
recipient: BanchoUser
}
/**
......
......@@ -21,7 +21,7 @@ class MessageCommand extends IrcCommand {
* @event BanchoClient#PM
* @type {PrivateMessage}
*/
client.emit("PM", new PrivateMessage(user, message, false));
client.emit("PM", new PrivateMessage(user, message, false, client.getSelf()));
else
/**
* Fired when a channel message reaches us.
......
......@@ -48,7 +48,7 @@ class OutgoingBanchoMessage {
if(this.banchojs.isConnected()) {
this.banchojs.send("PRIVMSG "+name+" :"+message, false);
if(this.recipient instanceof require("./BanchoUser"))
this.banchojs.emit("PM", new PrivateMessage(this.recipient, message, true));
this.banchojs.emit("PM", new PrivateMessage(this.banchojs.getSelf(), message, true, this.recipient));
else if(this.recipient instanceof require("./BanchoChannel"))
this.banchojs.emit("CM", new ChannelMessage(this.banchojs.getSelf(), message, true, this.recipient));
resolve();
......
......@@ -9,11 +9,13 @@ class PrivateMessage extends BanchoMessage {
/**
* @constructor
* @param {BanchoUser} user User the message was sent by
* @param {BanchoUser} recipient User the message was sent to
* @param {string} message Message body
* @param {boolean} self Set to true if this message was sent by this instance of bancho.js
*/
constructor(user, message, self) {
constructor(user, message, self, recipient) {
super(user, message, self);
this.recipient = recipient;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment