From 85330769a7b2625a96da431aca4e6c111c0a4273 Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Sun, 30 Oct 2016 16:55:08 -0400 Subject: [PATCH] Refactor OAuth application stuff --- src/client/Client.js | 6 +++--- src/client/rest/RESTMethods.js | 8 ++++---- src/index.js | 4 ++-- .../{ClientOAuth2App.js => ClientOAuth2Application.js} | 8 ++++---- src/structures/{OAuth2App.js => OAuth2Application.js} | 8 ++++---- src/util/Constants.js | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) rename src/structures/{ClientOAuth2App.js => ClientOAuth2Application.js} (63%) rename src/structures/{OAuth2App.js => OAuth2Application.js} (90%) diff --git a/src/client/Client.js b/src/client/Client.js index c1b088c36..03189c7d4 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -327,13 +327,13 @@ class Client extends EventEmitter { } /** - * Get's the bot's OAuth2 app. + * Gets the bot's OAuth2 application. * This is only available for bot accounts. * @returns {Promise} */ - 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) { diff --git a/src/client/rest/RESTMethods.js b/src/client/rest/RESTMethods.js index 1ca113289..52ec23205 100644 --- a/src/client/rest/RESTMethods.js +++ b/src/client/rest/RESTMethods.js @@ -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) ); } } diff --git a/src/index.js b/src/index.js index 0c845cd4b..cca40367a 100644 --- a/src/index.js +++ b/src/index.js @@ -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'), diff --git a/src/structures/ClientOAuth2App.js b/src/structures/ClientOAuth2Application.js similarity index 63% rename from src/structures/ClientOAuth2App.js rename to src/structures/ClientOAuth2Application.js index e3b1013b8..158d71a4f 100644 --- a/src/structures/ClientOAuth2App.js +++ b/src/structures/ClientOAuth2Application.js @@ -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; diff --git a/src/structures/OAuth2App.js b/src/structures/OAuth2Application.js similarity index 90% rename from src/structures/OAuth2App.js rename to src/structures/OAuth2Application.js index 89bcae805..9969c8ed6 100644 --- a/src/structures/OAuth2App.js +++ b/src/structures/OAuth2Application.js @@ -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; diff --git a/src/util/Constants.js b/src/util/Constants.js index d8015a73e..f21141b82 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -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}`, };