mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 13:02:38 +00:00
Merge pull request #3 from hydrabolt/indev
bring minor bug fixes so developers don't encounter them
This commit is contained in:
commit
c62f213994
2 changed files with 23 additions and 6 deletions
27
index.js
27
index.js
|
|
@ -17,7 +17,7 @@ exports.Client = function( options ) {
|
|||
this.websocket = null;
|
||||
this.events = {};
|
||||
this.user = null;
|
||||
|
||||
this.ready = false;
|
||||
this.serverList = new List( "id" );
|
||||
this.PMList = new List( "id" );
|
||||
|
||||
|
|
@ -25,6 +25,10 @@ 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!
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this.events[ event ] ) {
|
||||
this.events[ event ].apply( this, args );
|
||||
} else {
|
||||
|
|
@ -149,6 +153,7 @@ exports.Client.prototype.connectWebsocket = function( cb ) {
|
|||
client.cacheServer( sID, function( server ) {
|
||||
cached++;
|
||||
if ( cached >= toCache ) {
|
||||
client.ready = true;
|
||||
client.triggerEvent( "ready" );
|
||||
}
|
||||
}, _server.members );
|
||||
|
|
@ -210,7 +215,7 @@ exports.Client.prototype.connectWebsocket = function( cb ) {
|
|||
|
||||
if ( !srv.channels.filter( "id", dat.d.d, true ) ) {
|
||||
|
||||
var chann = new Channel(dat.d, srv);
|
||||
var chann = new Channel( dat.d, srv );
|
||||
|
||||
srv.channels.add( new Channel( dat.d, srv ) );
|
||||
client.triggerEvent( "channelCreate", [ chann ] );
|
||||
|
|
@ -383,6 +388,18 @@ exports.Client.prototype.sendMessage = function( channel, message, cb, _mentions
|
|||
}
|
||||
}
|
||||
|
||||
if ( channel instanceof Message ) { //if the channel is actually a message, get the channel
|
||||
channel = channel.channel;
|
||||
}
|
||||
|
||||
if ( typeof channel === 'string' || channel instanceof String || !isNaN( channel ) ) {
|
||||
//Channel is an ID
|
||||
var chanId = channel;
|
||||
channel = {
|
||||
id: chanId
|
||||
}
|
||||
}
|
||||
|
||||
var cb = cb || function() {};
|
||||
|
||||
if ( _mentions === false ) {
|
||||
|
|
@ -462,8 +479,8 @@ exports.Client.prototype.getChannelLogs = function( channel, amount, cb ) {
|
|||
.set( "authorization", client.token )
|
||||
.end( function( err, res ) {
|
||||
|
||||
if ( err ) {
|
||||
cb( new List( "id" ) );
|
||||
if ( !res.ok ) {
|
||||
cb( err );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -473,7 +490,7 @@ exports.Client.prototype.getChannelLogs = function( channel, amount, cb ) {
|
|||
datList.add( new Message( item, channel ) );
|
||||
}
|
||||
|
||||
cb( datList );
|
||||
cb( null, datList );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "discord.js",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "A way to interface with the Discord API",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue