mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
Finished most of structure
This commit is contained in:
38
lib/Structures/Message.js
Normal file
38
lib/Structures/Message.js
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Cache = require("../Util/Cache.js");
|
||||
var User = require("./User.js");
|
||||
|
||||
var Message = function Message(data, channel, client) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, Message);
|
||||
|
||||
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;
|
||||
|
||||
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)));
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = Message;
|
||||
Reference in New Issue
Block a user