Refactor OAuth application stuff

This commit is contained in:
Schuyler Cebulskie
2016-10-30 16:55:08 -04:00
parent 589c44327a
commit 85330769a7
6 changed files with 18 additions and 18 deletions

View File

@@ -327,13 +327,13 @@ class Client extends EventEmitter {
}
/**
* Get's the bot's OAuth2 app.
* Gets the bot's OAuth2 application.
* <warn>This is only available for bot accounts.</warn>
* @returns {Promise<ClientOAuth2App>}
*/
getMyApp() {
fetchApplication() {
if (!this.user.bot) throw new Error(Constants.Errors.NO_BOT_ACCOUNT);
return this.rest.methods.getMyApp();
return this.rest.methods.getMyApplication();
}
setTimeout(fn, ...params) {

View File

@@ -10,7 +10,7 @@ const Role = requireStructure('Role');
const Invite = requireStructure('Invite');
const Webhook = requireStructure('Webhook');
const UserProfile = requireStructure('UserProfile');
const ClientOAuth2App = requireStructure('ClientOAuth2App');
const ClientOAuth2Application = requireStructure('ClientOAuth2Application');
class RESTMethods {
constructor(restManager) {
@@ -611,9 +611,9 @@ class RESTMethods {
return this.rest.makeRequest('get', Constants.Endpoints.messageReaction(channelID, messageID, emoji, limit), true);
}
getMyApp() {
return this.rest.makeRequest('get', Constants.Endpoints.myApp, true).then(app =>
new ClientOAuth2App(this.rest.client, app)
getMyApplication() {
return this.rest.makeRequest('get', Constants.Endpoints.myApplication, true).then(app =>
new ClientOAuth2Application(this.rest.client, app)
);
}
}

View File

@@ -11,7 +11,7 @@ module.exports = {
fetchRecommendedShards: require('./util/FetchRecommendedShards'),
Channel: require('./structures/Channel'),
ClientOAuth2App: require('./structures/ClientOAuth2App'),
ClientOAuth2Application: require('./structures/ClientOAuth2Application'),
ClientUser: require('./structures/ClientUser'),
DMChannel: require('./structures/DMChannel'),
Emoji: require('./structures/Emoji'),
@@ -26,7 +26,7 @@ module.exports = {
MessageAttachment: require('./structures/MessageAttachment'),
MessageCollector: require('./structures/MessageCollector'),
MessageEmbed: require('./structures/MessageEmbed'),
OAuth2App: require('./structures/OAuth2App'),
OAuth2Application: require('./structures/OAuth2Application'),
PartialGuild: require('./structures/PartialGuild'),
PartialGuildChannel: require('./structures/PartialGuildChannel'),
PermissionOverwrites: require('./structures/PermissionOverwrites'),

View File

@@ -1,11 +1,11 @@
const User = require('./User');
const OAuth2App = require('./OAuth2App');
const OAuth2Application = require('./OAuth2Application');
/**
* Represents the client's OAuth2 Application
* @extends {OAuth2App}
* @extends {OAuth2Application}
*/
class ClientOAuth2App extends OAuth2App {
class ClientOAuth2Application extends OAuth2Application {
setup(data) {
super.setup(data);
@@ -23,4 +23,4 @@ class ClientOAuth2App extends OAuth2App {
}
}
module.exports = ClientOAuth2App;
module.exports = ClientOAuth2Application;

View File

@@ -1,10 +1,10 @@
/**
* Represents a OAuth2 Application
* Represents an OAuth2 Application
*/
class OAuth2App {
class OAuth2Application {
constructor(client, data) {
/**
* The client that instantiated the role
* The client that instantiated the application
* @type {Client}
*/
this.client = client;
@@ -78,4 +78,4 @@ class OAuth2App {
}
}
module.exports = OAuth2App;
module.exports = OAuth2Application;

View File

@@ -131,7 +131,7 @@ const Endpoints = exports.Endpoints = {
webhook: (webhookID, token) => `${API}/webhooks/${webhookID}${token ? `/${token}` : ''}`,
// oauth
myApp: `${API}/oauth2/applications/@me`,
myApplication: `${API}/oauth2/applications/@me`,
getApp: (id) => `${API}/oauth2/authorize?client_id=${id}`,
};