mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Added more properties to the server
This commit is contained in:
12
index.js
12
index.js
@@ -25,7 +25,7 @@ exports.Client = function( options ) {
|
||||
|
||||
exports.Client.prototype.triggerEvent = function( event, args ) {
|
||||
|
||||
if ( !this.ready ) { //if we're not even loaded yet, don't try doing anything because it always ends badly!
|
||||
if ( !this.ready && event !== "raw" ) { //if we're not even loaded yet, don't try doing anything because it always ends badly!
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ exports.Client.prototype.cacheServer = function( id, cb, members ) {
|
||||
.set( "authorization", this.token )
|
||||
.end( function( err, res ) {
|
||||
var dat = res.body;
|
||||
var server = new Server( dat.region, dat.owner_id, dat.name, dat.roles[ 0 ].id, members || dat.members );
|
||||
var server = new Server( dat.region, dat.owner_id, dat.name, dat.roles[ 0 ].id, members || dat.members, dat.icon, dat.afk_timeout, dat.afk_channel_id );
|
||||
|
||||
request
|
||||
.get( Endpoints.SERVERS + "/" + id + "/channels" )
|
||||
@@ -105,6 +105,14 @@ exports.Client.prototype.login = function( email, password ) {
|
||||
|
||||
}
|
||||
|
||||
exports.Client.prototype.reply = function(){
|
||||
|
||||
arguments[1] = arguments[0].author.mention() + ", " + arguments[1];
|
||||
|
||||
this.sendMessage.apply(this, arguments);
|
||||
|
||||
}
|
||||
|
||||
exports.Client.prototype.connectWebsocket = function( cb ) {
|
||||
|
||||
var client = this;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var User = require( "./user.js" ).User;
|
||||
var List = require( "./list.js" ).List;
|
||||
exports.Server = function( region, ownerID, name, id, members ) {
|
||||
exports.Server = function( region, ownerID, name, id, members, icon, afkTimeout, afkChannelId ) {
|
||||
|
||||
this.region = region;
|
||||
this.ownerID = ownerID;
|
||||
@@ -8,14 +8,32 @@ exports.Server = function( region, ownerID, name, id, members ) {
|
||||
this.id = id;
|
||||
this.members = new List( "id" );
|
||||
this.channels = new List( "id" );
|
||||
this.icon = icon;
|
||||
this.afkTimeout = afkTimeout;
|
||||
this.afkChannelId = afkChannelId;
|
||||
|
||||
for ( x in members ) {
|
||||
var member = members[ x ].user;
|
||||
this.members.add( new User( member ) );
|
||||
}
|
||||
}
|
||||
|
||||
exports.Server.prototype.getIconURL = function(){
|
||||
if(!this.icon)
|
||||
return false;
|
||||
return "https://discordapp.com/api/guilds/"+this.id+"/icons/"+this.icon+".jpg";
|
||||
}
|
||||
|
||||
exports.Server.prototype.getAFKChannel = function(){
|
||||
|
||||
if(!this.afkChannelId)
|
||||
return false;
|
||||
|
||||
return this.channels.filter("id", this.afkChannelId, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
exports.Server.prototype.getDefaultChannel = function() {
|
||||
|
||||
return this.channels.filter( "name", "general", true );
|
||||
|
||||
@@ -14,6 +14,12 @@ exports.User = function(username, id, discriminator, avatar){
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
exports.User.prototype.getAvatarURL = function(){
|
||||
if(!this.avatar)
|
||||
return false;
|
||||
return "https://discordapp.com/api/users/" + this.id + "/avatars/" + this.avatar + ".jpg";
|
||||
}
|
||||
|
||||
exports.User.prototype.mention = function(){
|
||||
return "<@"+this.id+">";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user