mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
Add debug stuff
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -25,8 +25,10 @@ class ClientManager {
|
|||||||
* @param {function} reject Function to run when connection fails
|
* @param {function} reject Function to run when connection fails
|
||||||
*/
|
*/
|
||||||
connectToWebSocket(token, resolve, reject) {
|
connectToWebSocket(token, resolve, reject) {
|
||||||
|
this.client.emit('debug', `authenticated using token ${token}`);
|
||||||
this.client.token = token;
|
this.client.token = token;
|
||||||
this.client.rest.methods.getGateway().then(gateway => {
|
this.client.rest.methods.getGateway().then(gateway => {
|
||||||
|
this.client.emit('debug', `using gateway ${gateway}`);
|
||||||
this.client.ws.connect(gateway);
|
this.client.ws.connect(gateway);
|
||||||
this.client.once(Constants.Events.READY, () => resolve(token));
|
this.client.once(Constants.Events.READY, () => resolve(token));
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class RESTMethods {
|
|||||||
|
|
||||||
loginEmailPassword(email, password) {
|
loginEmailPassword(email, password) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
this.rest.client.emit('debug', 'client launched using email and password - should use token instead');
|
||||||
this.rest.client.email = email;
|
this.rest.client.email = email;
|
||||||
this.rest.client.password = password;
|
this.rest.client.password = password;
|
||||||
this.rest.makeRequest('post', Constants.Endpoints.login, false, { email, password })
|
this.rest.makeRequest('post', Constants.Endpoints.login, false, { email, password })
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class WebSocketManager {
|
|||||||
* @param {string} gateway The gateway to connect to
|
* @param {string} gateway The gateway to connect to
|
||||||
*/
|
*/
|
||||||
connect(gateway) {
|
connect(gateway) {
|
||||||
|
this.client.emit('debug', `connecting to gateway ${gateway}`);
|
||||||
this.normalReady = false;
|
this.normalReady = false;
|
||||||
this.status = Constants.Status.CONNECTING;
|
this.status = Constants.Status.CONNECTING;
|
||||||
this.ws = new WebSocket(gateway);
|
this.ws = new WebSocket(gateway);
|
||||||
@@ -108,6 +109,7 @@ class WebSocketManager {
|
|||||||
* Run whenever the gateway connections opens up
|
* Run whenever the gateway connections opens up
|
||||||
*/
|
*/
|
||||||
eventOpen() {
|
eventOpen() {
|
||||||
|
this.client.emit('debug', 'connection to gateway opened');
|
||||||
if (this.reconnecting) this._sendResume();
|
if (this.reconnecting) this._sendResume();
|
||||||
else this._sendNewIdentify();
|
else this._sendNewIdentify();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ client.on('ready', () => {
|
|||||||
console.log('ready!');
|
console.log('ready!');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
client.on('debug', console.log);
|
||||||
|
|
||||||
client.on('message', message => {
|
client.on('message', message => {
|
||||||
if (true) {
|
if (true) {
|
||||||
if (message.content === 'makechann') {
|
if (message.content === 'makechann') {
|
||||||
|
|||||||
Reference in New Issue
Block a user