Finished embeds

This commit is contained in:
hydrabolt
2015-10-29 14:48:39 +00:00
parent cefbcd05af
commit 0938382e51
13 changed files with 146 additions and 28 deletions

View File

@@ -9,6 +9,7 @@ var PMChannel = require("./PMChannel.js");
var ServerPermissions = require("./ServerPermissions.js");
var gameMap = require("../ref/gameMap.json");
var Color = require("../ref/colours.js");
var Embeddable = require("./Embeds/IEmbed.js");
var zlib;
var EventEmitter = require('events');

View File

@@ -1,6 +1,20 @@
class Embed{
constructor(data){
this.url = data.url;
this.type = data.type;
this.title = data.title;
this.thumbnail = data.thumbnail;
//width
//height
//url
//proxy_url
this.provider = data.provider;
//url
//name
this.description = data.description;
this.author = data.author;
//url
//name
}
}

17
src/Embeds/IEmbed.js Normal file
View File

@@ -0,0 +1,17 @@
var ImageEmbed = require("./ImageEmbed.js"),
VideoEmbed = require("./VideoEmbed.js"),
LinkEmbed = require("./LinkEmbed.js");
exports.createEmbed = function(data){
switch(data.type){
case "image":
return new ImageEmbed(data);
break;
case "video":
return new VideoEmbed(data);
break;
case "link":
return new LinkEmbed(data);
break;
}
}

View File

@@ -3,6 +3,10 @@ var Embed = require("./Embed.js");
class VideoEmbed extends Embed{
constructor(data){
super(data);
this.video = data.video;
//width
//height
//url
}
}

View File

@@ -17,7 +17,11 @@ var Discord = {
ChannelPermissions : require("./ChannelPermissions.js"),
EvaluatedPermissiosn : require("./EvaluatedPermissions.js"),
VoiceChannel : require("./VoiceChannel.js"),
gameMap : require("../ref/gameMap.json")
gameMap : require("../ref/gameMap.json"),
Embed : require("./Embeds/Embed.js"),
LinkEmbed : require("./Embeds/LinkEmbed.js"),
VideoEmbed : require("./Embeds/VideoEmbed.js"),
ImageEmbed : require("./Embeds/ImageEmbed.js"),
}
Discord.patchStrings = function () {

View File

@@ -1,42 +1,50 @@
var PMChannel = require("./PMChannel.js");
var Embeddable = require("./Embeds/IEmbed.js");
class Message{
constructor(data, channel, mentions, author){
class Message {
constructor(data, channel, mentions, author) {
this.tts = data.tts;
this.timestamp = Date.parse(data.timestamp);
this.nonce = data.nonce;
this.mentions = mentions;
this.everyoneMentioned = data.mention_everyone;
this.id = data.id;
this.embeds = data.embeds;
this.embeds = [];
if (data.embeds) {
for (var embed of data.embeds) {
this.embeds.push( Embeddable.createEmbed(embed) );
}
}
this.editedTimestamp = data.edited_timestamp;
this.content = data.content.trim();
this.channel = channel;
if(this.isPrivate){
if (this.isPrivate) {
this.author = this.channel.client.getUser("id", author.id);
}else{
} else {
this.author = this.channel.server.getMember("id", author.id) || this.channel.client.getUser("id", author.id);
}
this.attachments = data.attachments;
}
isMentioned( user ){
isMentioned(user) {
var id = (user.id ? user.id : user);
for(var mention of this.mentions){
if(mention.id === id){
for (var mention of this.mentions) {
if (mention.id === id) {
return true;
}
}
return false;
}
get sender(){
get sender() {
return this.author;
}
get isPrivate(){
get isPrivate() {
return this.channel.isPrivate;
}
}