mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Most arrays are now using lists.
This commit is contained in:
@@ -1,37 +1,32 @@
|
||||
var User = require("./user.js").User;
|
||||
var User = require( "./user.js" ).User;
|
||||
var List = require( "./list.js" ).List;
|
||||
|
||||
exports.Message = function(time, author, content, channel, id, mentions){
|
||||
exports.Message = function( time, author, content, channel, id, mentions, everyoneMentioned ) {
|
||||
|
||||
if(!content){
|
||||
message = time;
|
||||
channel = author;
|
||||
time = message.timestamp;
|
||||
author = message.author;
|
||||
content = message.content;
|
||||
id = message.id;
|
||||
mentions = message.mentions;
|
||||
}
|
||||
if ( !content ) {
|
||||
message = time;
|
||||
channel = author;
|
||||
time = message.timestamp;
|
||||
author = message.author;
|
||||
content = message.content;
|
||||
id = message.id;
|
||||
mentions = message.mentions;
|
||||
everyoneMentioned = message.mention_everyone;
|
||||
}
|
||||
|
||||
this.time = Date.parse(time);
|
||||
this.author = new User(author);
|
||||
this.content = content.replace(/<[^>]*>/g, "").replace(/\s+/g, ' ').trim();
|
||||
this.channel = channel;
|
||||
this.id = id;
|
||||
this.mentions = mentions || [];
|
||||
for(x in mentions){
|
||||
var _mention = mentions[x];
|
||||
this.mentions.push( new User(_mention.username, _mention.id, _mention.discriminator, _mention.avatar) );
|
||||
}
|
||||
this.time = Date.parse( time );
|
||||
this.author = new User( author );
|
||||
this.content = content.replace( /\s+/g, ' ' ).trim(); //content.replace(/<[^>]*>/g, "").replace(/\s+/g, ' ').trim();
|
||||
this.channel = channel;
|
||||
this.id = id;
|
||||
this.mentions = new List( "id" );
|
||||
this.everyoneMentioned = everyoneMentioned;
|
||||
for ( x in mentions ) {
|
||||
var _mention = mentions[ x ];
|
||||
this.mentions.add( new User( _mention ) );
|
||||
}
|
||||
}
|
||||
|
||||
exports.Message.prototype.isMentioned = function(user){
|
||||
|
||||
for(mention of this.mentions){
|
||||
if(user.equals(mention)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
exports.Message.prototype.isMentioned = function( user ) {
|
||||
return ( this.mentions.filter( "id", user.id ).length > 0 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user