mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
Refactor OAuth application stuff
This commit is contained in:
@@ -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>
|
* <warn>This is only available for bot accounts.</warn>
|
||||||
* @returns {Promise<ClientOAuth2App>}
|
* @returns {Promise<ClientOAuth2App>}
|
||||||
*/
|
*/
|
||||||
getMyApp() {
|
fetchApplication() {
|
||||||
if (!this.user.bot) throw new Error(Constants.Errors.NO_BOT_ACCOUNT);
|
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) {
|
setTimeout(fn, ...params) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const Role = requireStructure('Role');
|
|||||||
const Invite = requireStructure('Invite');
|
const Invite = requireStructure('Invite');
|
||||||
const Webhook = requireStructure('Webhook');
|
const Webhook = requireStructure('Webhook');
|
||||||
const UserProfile = requireStructure('UserProfile');
|
const UserProfile = requireStructure('UserProfile');
|
||||||
const ClientOAuth2App = requireStructure('ClientOAuth2App');
|
const ClientOAuth2Application = requireStructure('ClientOAuth2Application');
|
||||||
|
|
||||||
class RESTMethods {
|
class RESTMethods {
|
||||||
constructor(restManager) {
|
constructor(restManager) {
|
||||||
@@ -611,9 +611,9 @@ class RESTMethods {
|
|||||||
return this.rest.makeRequest('get', Constants.Endpoints.messageReaction(channelID, messageID, emoji, limit), true);
|
return this.rest.makeRequest('get', Constants.Endpoints.messageReaction(channelID, messageID, emoji, limit), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMyApp() {
|
getMyApplication() {
|
||||||
return this.rest.makeRequest('get', Constants.Endpoints.myApp, true).then(app =>
|
return this.rest.makeRequest('get', Constants.Endpoints.myApplication, true).then(app =>
|
||||||
new ClientOAuth2App(this.rest.client, app)
|
new ClientOAuth2Application(this.rest.client, app)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ module.exports = {
|
|||||||
fetchRecommendedShards: require('./util/FetchRecommendedShards'),
|
fetchRecommendedShards: require('./util/FetchRecommendedShards'),
|
||||||
|
|
||||||
Channel: require('./structures/Channel'),
|
Channel: require('./structures/Channel'),
|
||||||
ClientOAuth2App: require('./structures/ClientOAuth2App'),
|
ClientOAuth2Application: require('./structures/ClientOAuth2Application'),
|
||||||
ClientUser: require('./structures/ClientUser'),
|
ClientUser: require('./structures/ClientUser'),
|
||||||
DMChannel: require('./structures/DMChannel'),
|
DMChannel: require('./structures/DMChannel'),
|
||||||
Emoji: require('./structures/Emoji'),
|
Emoji: require('./structures/Emoji'),
|
||||||
@@ -26,7 +26,7 @@ module.exports = {
|
|||||||
MessageAttachment: require('./structures/MessageAttachment'),
|
MessageAttachment: require('./structures/MessageAttachment'),
|
||||||
MessageCollector: require('./structures/MessageCollector'),
|
MessageCollector: require('./structures/MessageCollector'),
|
||||||
MessageEmbed: require('./structures/MessageEmbed'),
|
MessageEmbed: require('./structures/MessageEmbed'),
|
||||||
OAuth2App: require('./structures/OAuth2App'),
|
OAuth2Application: require('./structures/OAuth2Application'),
|
||||||
PartialGuild: require('./structures/PartialGuild'),
|
PartialGuild: require('./structures/PartialGuild'),
|
||||||
PartialGuildChannel: require('./structures/PartialGuildChannel'),
|
PartialGuildChannel: require('./structures/PartialGuildChannel'),
|
||||||
PermissionOverwrites: require('./structures/PermissionOverwrites'),
|
PermissionOverwrites: require('./structures/PermissionOverwrites'),
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
const User = require('./User');
|
const User = require('./User');
|
||||||
const OAuth2App = require('./OAuth2App');
|
const OAuth2Application = require('./OAuth2Application');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the client's OAuth2 Application
|
* Represents the client's OAuth2 Application
|
||||||
* @extends {OAuth2App}
|
* @extends {OAuth2Application}
|
||||||
*/
|
*/
|
||||||
class ClientOAuth2App extends OAuth2App {
|
class ClientOAuth2Application extends OAuth2Application {
|
||||||
setup(data) {
|
setup(data) {
|
||||||
super.setup(data);
|
super.setup(data);
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ class ClientOAuth2App extends OAuth2App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ClientOAuth2App;
|
module.exports = ClientOAuth2Application;
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* Represents a OAuth2 Application
|
* Represents an OAuth2 Application
|
||||||
*/
|
*/
|
||||||
class OAuth2App {
|
class OAuth2Application {
|
||||||
constructor(client, data) {
|
constructor(client, data) {
|
||||||
/**
|
/**
|
||||||
* The client that instantiated the role
|
* The client that instantiated the application
|
||||||
* @type {Client}
|
* @type {Client}
|
||||||
*/
|
*/
|
||||||
this.client = client;
|
this.client = client;
|
||||||
@@ -78,4 +78,4 @@ class OAuth2App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = OAuth2App;
|
module.exports = OAuth2Application;
|
||||||
@@ -131,7 +131,7 @@ const Endpoints = exports.Endpoints = {
|
|||||||
webhook: (webhookID, token) => `${API}/webhooks/${webhookID}${token ? `/${token}` : ''}`,
|
webhook: (webhookID, token) => `${API}/webhooks/${webhookID}${token ? `/${token}` : ''}`,
|
||||||
|
|
||||||
// oauth
|
// oauth
|
||||||
myApp: `${API}/oauth2/applications/@me`,
|
myApplication: `${API}/oauth2/applications/@me`,
|
||||||
getApp: (id) => `${API}/oauth2/authorize?client_id=${id}`,
|
getApp: (id) => `${API}/oauth2/authorize?client_id=${id}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user