mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
Finished embeds
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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
17
src/Embeds/IEmbed.js
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,10 @@ var Embed = require("./Embed.js");
|
||||
class VideoEmbed extends Embed{
|
||||
constructor(data){
|
||||
super(data);
|
||||
this.video = data.video;
|
||||
//width
|
||||
//height
|
||||
//url
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user