mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
initial
This commit is contained in:
37
src/client/rest/RESTMethods.js
Normal file
37
src/client/rest/RESTMethods.js
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
const Constants = require('../../util/Constants');
|
||||
|
||||
class RESTMethods{
|
||||
constructor(restManager) {
|
||||
this.rest = restManager;
|
||||
}
|
||||
|
||||
LoginEmailPassword(email, password) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
this.rest.makeRequest('post', Constants.Endpoints.LOGIN, false, { email, password })
|
||||
.then(data => {
|
||||
this.rest.client.manager.connectToWebSocket(data.token, resolve, reject);
|
||||
})
|
||||
.catch(reject);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
LoginToken(token) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.rest.client.manager.connectToWebSocket(token, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
GetGateway() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.rest.makeRequest('get', Constants.Endpoints.GATEWAY, true)
|
||||
.then(res => resolve(res.url))
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RESTMethods;
|
||||
Reference in New Issue
Block a user