Added message sending

This commit is contained in:
hydrabolt
2015-10-31 22:59:53 +00:00
parent cc3f9d931a
commit 28308433da
14 changed files with 585 additions and 82 deletions

View File

@@ -5,34 +5,41 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var Cache = require("../Util/Cache.js");
var User = require("./User.js");
var Message = function Message(data, channel, client) {
var _this = this;
var Message = (function () {
function Message(data, channel, client) {
var _this = this;
_classCallCheck(this, Message);
_classCallCheck(this, Message);
this.channel = channel;
this.client = client;
this.channel = channel;
this.client = client;
this.nonce = data.nonce;
this.attachments = data.attachments;
this.tts = data.tts;
this.embeds = data.embeds;
this.timestamp = Date.parse(data.timestamp);
this.everyoneMentioned = data.mention_everyone;
this.id = data.id;
this.nonce = data.nonce;
this.attachments = data.attachments;
this.tts = data.tts;
this.embeds = data.embeds;
this.timestamp = Date.parse(data.timestamp);
this.everyoneMentioned = data.mention_everyone;
this.id = data.id;
if (data.edited_timestamp) this.editedTimestamp = Date.parse(data.edited_timestamp);
this.author = client.internal.users.add(new User(data.author, client));
this.content = data.content;
this.mentions = new Cache();
if (data.edited_timestamp) this.editedTimestamp = Date.parse(data.edited_timestamp);
this.author = client.internal.users.add(new User(data.author, client));
this.content = data.content;
this.mentions = new Cache();
data.mentions.forEach(function (mention) {
// this is .add and not .get because it allows the bot to cache
// users from messages from logs who may have left the server and were
// not previously cached.
console.log(mention);
_this.mentions.add(client.internal.users.add(new User(mention, client)));
});
};
data.mentions.forEach(function (mention) {
// this is .add and not .get because it allows the bot to cache
// users from messages from logs who may have left the server and were
// not previously cached.
_this.mentions.add(client.internal.users.add(new User(mention, client)));
});
}
Message.prototype.toString = function toString() {
return this.content;
};
return Message;
})();
module.exports = Message;

View File

@@ -26,6 +26,10 @@ var PMChannel = (function (_Equality) {
/* warning! may return null */
PMChannel.prototype.toString = function toString() {
return this.recipient.toString();
};
_createClass(PMChannel, [{
key: "lastMessage",
get: function get() {

View File

@@ -17,6 +17,7 @@ var ServerChannel = (function (_Channel) {
_classCallCheck(this, ServerChannel);
_Channel.call(this, data, client);
this.name = data.name;
this.type = data.type;
this.permissionOverwrites = new Cache();
data.permission_overwrites.forEach(function (permission) {
@@ -24,6 +25,10 @@ var ServerChannel = (function (_Channel) {
});
}
ServerChannel.prototype.toString = function toString() {
return this.name;
};
return ServerChannel;
})(Channel);