mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
1.0.1 actual
works!
This commit is contained in:
19
lib/channel.js
Normal file
19
lib/channel.js
Normal file
@@ -0,0 +1,19 @@
|
||||
exports.Channel = function(name, serverId, type, id, isPrivate){
|
||||
|
||||
this.name = name;
|
||||
this.serverId = serverId;
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
this.isPrivate = isPrivate;
|
||||
|
||||
}
|
||||
|
||||
exports.Channel.equals = function(otherChannel){
|
||||
|
||||
if(otherChannel.id === this.id){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
11
lib/endpoints.js
Normal file
11
lib/endpoints.js
Normal file
@@ -0,0 +1,11 @@
|
||||
var base = "https://discordapp.com/";
|
||||
var apibase = base + "api";
|
||||
|
||||
exports.WEBSOCKET_HUB = "wss://discordapp.com/hub"
|
||||
|
||||
exports.LOGIN = apibase + "/auth/login";
|
||||
exports.LOGOUT = apibase + "/auth/logout";
|
||||
|
||||
exports.SERVERS = apibase + "/guilds";
|
||||
|
||||
exports.CHANNELS = apibase + "/channels";
|
||||
26
lib/message.js
Normal file
26
lib/message.js
Normal file
@@ -0,0 +1,26 @@
|
||||
var User = require("./user.js").User;
|
||||
|
||||
exports.Message = function(time, author, content, channel, id, mentions){
|
||||
this.time = Date.parse(time);
|
||||
this.author = new User(author.username, author.id, author.discriminator, author.avatar);
|
||||
this.content = content.replace(/<[^>]*>/g, "").replace(/\s+/g, ' ').trim();
|
||||
this.channel = channel;
|
||||
this.id = id;
|
||||
this.mentions = [];
|
||||
for(x in mentions){
|
||||
var _mention = mentions[x];
|
||||
this.mentions.push( new User(_mention.username, _mention.id, _mention.discriminator, _mention.avatar) );
|
||||
}
|
||||
}
|
||||
|
||||
exports.Message.prototype.isMentioned = function(user){
|
||||
|
||||
for(mention of this.mentions){
|
||||
if(user.equals(mention)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
15
lib/server.js
Normal file
15
lib/server.js
Normal file
@@ -0,0 +1,15 @@
|
||||
var User = require("./user.js").User;
|
||||
|
||||
exports.Server = function(region, ownerID, name, id, members){
|
||||
|
||||
this.region = region;
|
||||
this.ownerID = ownerID;
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.members = [];
|
||||
for(x in members){
|
||||
var _member = members[x].user;
|
||||
this.members.push( new User(_member.username, _member.id, _member.discriminator, _member.avatar) );
|
||||
}
|
||||
|
||||
}
|
||||
20
lib/user.js
Normal file
20
lib/user.js
Normal file
@@ -0,0 +1,20 @@
|
||||
exports.User = function(username, id, discriminator, avatar){
|
||||
this.username = username;
|
||||
this.discriminator = discriminator;
|
||||
this.id = id;
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
exports.User.prototype.mention = function(){
|
||||
return "<@"+this.id+">";
|
||||
}
|
||||
|
||||
exports.User.prototype.equals = function(otherUser){
|
||||
|
||||
if(otherUser.id === this.id){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user