chore(release): v2.3.7
- docs: Add `MessageActivityType` (v13) #8257 - Developer Portal control support (create, delete) - Application: create bot, reset secret, token, delete, edit, assets
This commit is contained in:
parent
fa174ebd9e
commit
aae4b3d1d9
File diff suppressed because one or more lines are too long
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "discord.js-selfbot-v13",
|
"name": "discord.js-selfbot-v13",
|
||||||
"version": "2.3.67",
|
"version": "2.3.7",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "discord.js-selfbot-v13",
|
"name": "discord.js-selfbot-v13",
|
||||||
"version": "2.3.67",
|
"version": "2.3.7",
|
||||||
"license": "GNU General Public License v3.0",
|
"license": "GNU General Public License v3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aikochan2k6/qrcode-terminal": "^0.12.0",
|
"@aikochan2k6/qrcode-terminal": "^0.12.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord.js-selfbot-v13",
|
"name": "discord.js-selfbot-v13",
|
||||||
"version": "2.3.68",
|
"version": "2.3.7",
|
||||||
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
|
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
|
||||||
"main": "./src/index.js",
|
"main": "./src/index.js",
|
||||||
"types": "./typings/index.d.ts",
|
"types": "./typings/index.d.ts",
|
||||||
|
@ -12,6 +12,7 @@ const { Error, TypeError, RangeError } = require('../errors');
|
|||||||
const BaseGuildEmojiManager = require('../managers/BaseGuildEmojiManager');
|
const BaseGuildEmojiManager = require('../managers/BaseGuildEmojiManager');
|
||||||
const ChannelManager = require('../managers/ChannelManager');
|
const ChannelManager = require('../managers/ChannelManager');
|
||||||
const ClientUserSettingManager = require('../managers/ClientUserSettingManager');
|
const ClientUserSettingManager = require('../managers/ClientUserSettingManager');
|
||||||
|
const DeveloperPortalManager = require('../managers/DeveloperPortalManager');
|
||||||
const GuildManager = require('../managers/GuildManager');
|
const GuildManager = require('../managers/GuildManager');
|
||||||
const RelationshipsManager = require('../managers/RelationshipsManager');
|
const RelationshipsManager = require('../managers/RelationshipsManager');
|
||||||
const UserManager = require('../managers/UserManager');
|
const UserManager = require('../managers/UserManager');
|
||||||
@ -165,6 +166,12 @@ class Client extends BaseClient {
|
|||||||
*/
|
*/
|
||||||
this.sweepers = new Sweepers(this, this.options.sweepers);
|
this.sweepers = new Sweepers(this, this.options.sweepers);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The developer portal manager of the client
|
||||||
|
* @type {DeveloperPortalManager}
|
||||||
|
*/
|
||||||
|
this.developerPortal = new DeveloperPortalManager(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The presence of the Client
|
* The presence of the Client
|
||||||
* @private
|
* @private
|
||||||
|
@ -2,15 +2,16 @@
|
|||||||
|
|
||||||
const { default: Collection } = require('@discordjs/collection');
|
const { default: Collection } = require('@discordjs/collection');
|
||||||
// Not used: const { remove } = require('lodash');
|
// Not used: const { remove } = require('lodash');
|
||||||
|
const BaseManager = require('./BaseManager');
|
||||||
const { Error, TypeError } = require('../errors/DJSError');
|
const { Error, TypeError } = require('../errors/DJSError');
|
||||||
const { localeObject, DMScanLevel, stickerAnimationMode } = require('../util/Constants');
|
const { localeObject, DMScanLevel, stickerAnimationMode } = require('../util/Constants');
|
||||||
/**
|
/**
|
||||||
* Manages API methods for users and stores their cache.
|
* Manages API methods for users and stores their cache.
|
||||||
* @extends {CachedManager}
|
* @extends {BaseManager}
|
||||||
*/
|
*/
|
||||||
class ClientUserSettingManager {
|
class ClientUserSettingManager extends BaseManager {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
this.client = client;
|
super(client);
|
||||||
// Raw data
|
// Raw data
|
||||||
this.rawSetting = {};
|
this.rawSetting = {};
|
||||||
// Language
|
// Language
|
||||||
@ -209,7 +210,7 @@ class ClientUserSettingManager {
|
|||||||
* @typedef {Object} CustomStatusOption
|
* @typedef {Object} CustomStatusOption
|
||||||
* @property {string | null} text Text to set
|
* @property {string | null} text Text to set
|
||||||
* @property {string | null} status The status to set: 'online', 'idle', 'dnd', 'invisible' or null.
|
* @property {string | null} status The status to set: 'online', 'idle', 'dnd', 'invisible' or null.
|
||||||
* @property {any} emoji UnicodeEmoji, DiscordEmoji, or null.
|
* @property {EmojiResolvable | null} emoji UnicodeEmoji, DiscordEmoji, or null.
|
||||||
* @property {number | null} expires The number of seconds until the status expires, or null.
|
* @property {number | null} expires The number of seconds until the status expires, or null.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
88
src/managers/DeveloperPortalManager.js
Normal file
88
src/managers/DeveloperPortalManager.js
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const BaseManager = require('./BaseManager');
|
||||||
|
const DeveloperPortalApplication = require('../structures/DeveloperPortalApplication');
|
||||||
|
const Team = require('../structures/Team');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages API methods for users and stores their cache.
|
||||||
|
* @extends {BaseManager}
|
||||||
|
*/
|
||||||
|
class DeveloperPortalManager extends BaseManager {
|
||||||
|
constructor(client) {
|
||||||
|
super(client);
|
||||||
|
/**
|
||||||
|
* A collection of all the applications the client has.
|
||||||
|
* @type {Collection<Snowflake, DeveloperPortalApplication>}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
this.applications = new Collection();
|
||||||
|
/**
|
||||||
|
* A collection of all the teams the client has.
|
||||||
|
* @type {Collection<Snowflake, Team>}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
this.teams = new Collection(); // Collection<Snowflake, Team>
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Fetches all the applications & teams the client has.
|
||||||
|
* @returns {Promise<DeveloperPortalManager>}
|
||||||
|
*/
|
||||||
|
async fetch() {
|
||||||
|
const promise1 = this.client.api.applications.get({
|
||||||
|
query: {
|
||||||
|
with_team_applications: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const promise2 = this.client.api.teams.get();
|
||||||
|
const [applications, teams] = await Promise.all([promise1, promise2]);
|
||||||
|
for (const team of teams) {
|
||||||
|
this.teams.set(team.id, new Team(this.client, team));
|
||||||
|
}
|
||||||
|
for (const application of applications) {
|
||||||
|
this.applications.set(application.id, new DeveloperPortalApplication(this.client, application));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new application.
|
||||||
|
* @param {string} name Name of the application
|
||||||
|
* @param {?Snowflake} teamId The team to create the application in
|
||||||
|
* @returns {Promise<DeveloperPortalApplication>}
|
||||||
|
*/
|
||||||
|
async createApplication(name, teamId = null) {
|
||||||
|
teamId = teamId instanceof Team ? teamId.id : teamId;
|
||||||
|
const application = await this.client.api.applications.post({
|
||||||
|
data: {
|
||||||
|
name,
|
||||||
|
team_id: teamId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.applications.set(application.id, new DeveloperPortalApplication(this.client, application));
|
||||||
|
return this.applications.get(application.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes an application.
|
||||||
|
* @param {Snowflake} id Application ID
|
||||||
|
* @param {?number} MFACode 2FA code (if 2FA is enabled)
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async deleteApplication(id, MFACode) {
|
||||||
|
if (MFACode) {
|
||||||
|
await this.client.api.applications[`${id}/delete`].post({
|
||||||
|
query: {
|
||||||
|
code: MFACode,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await this.client.api.applications[`${id}/delete`].post();
|
||||||
|
}
|
||||||
|
this.applications.delete(id);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = DeveloperPortalManager;
|
462
src/structures/DeveloperPortalApplication.js
Normal file
462
src/structures/DeveloperPortalApplication.js
Normal file
@ -0,0 +1,462 @@
|
|||||||
|
'use strict';
|
||||||
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const Base = require('./Base');
|
||||||
|
const ApplicationFlags = require('../util/ApplicationFlags');
|
||||||
|
const { ClientApplicationAssetTypes, Endpoints } = require('../util/Constants');
|
||||||
|
const DataResolver = require('../util/DataResolver');
|
||||||
|
const Permissions = require('../util/Permissions');
|
||||||
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||||
|
|
||||||
|
const AssetTypes = Object.keys(ClientApplicationAssetTypes);
|
||||||
|
|
||||||
|
class DeveloperPortalApplication extends Base {
|
||||||
|
constructor(client, data) {
|
||||||
|
super(client);
|
||||||
|
this._patch(data);
|
||||||
|
}
|
||||||
|
_patch(data) {
|
||||||
|
/**
|
||||||
|
* The application's id
|
||||||
|
* @type {Snowflake}
|
||||||
|
*/
|
||||||
|
this.id = data.id;
|
||||||
|
|
||||||
|
if ('name' in data) {
|
||||||
|
/**
|
||||||
|
* The name of the application
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.name = data.name;
|
||||||
|
} else {
|
||||||
|
this.name ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('description' in data) {
|
||||||
|
/**
|
||||||
|
* The application's description
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.description = data.description;
|
||||||
|
} else {
|
||||||
|
this.description ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('icon' in data) {
|
||||||
|
/**
|
||||||
|
* The application's icon hash
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.icon = data.icon;
|
||||||
|
} else {
|
||||||
|
this.icon ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('bot' in data) {
|
||||||
|
/**
|
||||||
|
* Bot application
|
||||||
|
* @type {User}
|
||||||
|
*/
|
||||||
|
this.bot = this.client.users._add(data.bot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tags this application has (max of 5)
|
||||||
|
* @type {string[]}
|
||||||
|
*/
|
||||||
|
this.tags = data.tags ?? [];
|
||||||
|
|
||||||
|
if ('install_params' in data) {
|
||||||
|
/**
|
||||||
|
* Settings for this application's default in-app authorization
|
||||||
|
* @type {?ClientApplicationInstallParams}
|
||||||
|
*/
|
||||||
|
this.installParams = {
|
||||||
|
scopes: data.install_params.scopes,
|
||||||
|
permissions: new Permissions(data.install_params.permissions).freeze(),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this.installParams ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('custom_install_url' in data) {
|
||||||
|
/**
|
||||||
|
* This application's custom installation URL
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.customInstallURL = data.custom_install_url;
|
||||||
|
} else {
|
||||||
|
this.customInstallURL = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('flags' in data) {
|
||||||
|
/**
|
||||||
|
* The flags this application has
|
||||||
|
* @type {ApplicationFlags}
|
||||||
|
*/
|
||||||
|
this.flags = new ApplicationFlags(data.flags).freeze();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('cover_image' in data) {
|
||||||
|
/**
|
||||||
|
* The hash of the application's cover image
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.cover = data.cover_image;
|
||||||
|
} else {
|
||||||
|
this.cover ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('rpc_origins' in data) {
|
||||||
|
/**
|
||||||
|
* The application's RPC origins, if enabled
|
||||||
|
* @type {string[]}
|
||||||
|
*/
|
||||||
|
this.rpcOrigins = data.rpc_origins;
|
||||||
|
} else {
|
||||||
|
this.rpcOrigins ??= [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('bot_require_code_grant' in data) {
|
||||||
|
/**
|
||||||
|
* If this application's bot requires a code grant when using the OAuth2 flow
|
||||||
|
* @type {?boolean}
|
||||||
|
*/
|
||||||
|
this.botRequireCodeGrant = data.bot_require_code_grant;
|
||||||
|
} else {
|
||||||
|
this.botRequireCodeGrant ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('bot_public' in data) {
|
||||||
|
/**
|
||||||
|
* If this application's bot is public
|
||||||
|
* @type {?boolean}
|
||||||
|
*/
|
||||||
|
this.botPublic = data.bot_public;
|
||||||
|
} else {
|
||||||
|
this.botPublic ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The owner of this OAuth application
|
||||||
|
* @type {?(User|Team)}
|
||||||
|
*/
|
||||||
|
this.owner = null;
|
||||||
|
if (data.owner.username == `team${data.owner.id}` && data.owner.discriminator == '0000') {
|
||||||
|
this.owner = this.client.developerPortal.teams.get(data.owner.id);
|
||||||
|
} else {
|
||||||
|
this.owner = data.owner ? this.client.users._add(data.owner) : this.owner ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect URIs for this application
|
||||||
|
* @type {Array<string>}
|
||||||
|
*/
|
||||||
|
this.redirectURIs = data.redirect_uris ?? [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BOT_HTTP_INTERACTIONS feature flag
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.interactionEndpointURL = data.interactions_endpoint_url ?? null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public key
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.publicKey = data.verify_key ?? null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Tester
|
||||||
|
* @property {number} state The state of the tester (2: Accepted, 1: Pending)
|
||||||
|
* @property {User} user The user that the tester is
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* User tester
|
||||||
|
* @type {Collection<Snowflake, Tester>}
|
||||||
|
*/
|
||||||
|
this.testers = new Collection(); // <Snowflake, User>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terms of service URL
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.TermsOfService = data.terms_of_service_url ?? null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Privacy policy URL
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.PrivacyPolicy = data.privacy_policy_url ?? null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The timestamp the application was created at
|
||||||
|
* @type {number}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get createdTimestamp() {
|
||||||
|
return SnowflakeUtil.timestampFrom(this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time the application was created at
|
||||||
|
* @type {Date}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get createdAt() {
|
||||||
|
return new Date(this.createdTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A link to the application's icon.
|
||||||
|
* @param {StaticImageURLOptions} [options={}] Options for the Image URL
|
||||||
|
* @returns {?string}
|
||||||
|
*/
|
||||||
|
iconURL({ format, size } = {}) {
|
||||||
|
if (!this.icon) return null;
|
||||||
|
return this.client.rest.cdn.AppIcon(this.id, this.icon, { format, size });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A link to this application's cover image.
|
||||||
|
* @param {StaticImageURLOptions} [options={}] Options for the Image URL
|
||||||
|
* @returns {?string}
|
||||||
|
*/
|
||||||
|
coverURL({ format, size } = {}) {
|
||||||
|
if (!this.cover) return null;
|
||||||
|
return Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id, this.cover, { format, size });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asset data.
|
||||||
|
* @typedef {Object} ApplicationAsset
|
||||||
|
* @property {Snowflake} id The asset's id
|
||||||
|
* @property {string} name The asset's name
|
||||||
|
* @property {string} type The asset's type
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the application's rich presence assets.
|
||||||
|
* @returns {Promise<Array<ApplicationAsset>>}
|
||||||
|
* @deprecated This will be removed in the next major as it is unsupported functionality.
|
||||||
|
*/
|
||||||
|
async fetchAssets() {
|
||||||
|
const assets = await this.client.api.oauth2.applications(this.id).assets.get();
|
||||||
|
return assets.map(a => ({
|
||||||
|
id: a.id,
|
||||||
|
name: a.name,
|
||||||
|
type: AssetTypes[a.type - 1],
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this application is partial
|
||||||
|
* @type {boolean}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get partial() {
|
||||||
|
return !this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains this application from Discord.
|
||||||
|
* @returns {Promise<DeveloperPortalApplication>}
|
||||||
|
*/
|
||||||
|
async fetch() {
|
||||||
|
const app = await this.client.api.applications[this.id].get();
|
||||||
|
this._patch(app);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all testers for this application.
|
||||||
|
* @returns {Promise<DeveloperPortalApplication>}
|
||||||
|
*/
|
||||||
|
async fetchTesters() {
|
||||||
|
const app = await this.client.api.applications[this.id].allowlist.get();
|
||||||
|
this.testers = new Collection();
|
||||||
|
for (const tester of app || []) {
|
||||||
|
this.testers.set(tester.user.id, {
|
||||||
|
state: tester.state,
|
||||||
|
user: this.client.users._add(tester.user),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add user to this application's allowlist.
|
||||||
|
* @param {string} username Username of the user to add
|
||||||
|
* @param {string} discriminator Discriminator of the user to add
|
||||||
|
* @returns {Promise<DeveloperPortalApplication>}
|
||||||
|
*/
|
||||||
|
async addTester(username, discriminator) {
|
||||||
|
const app = await this.client.api.applications[this.id].allowlist.post({
|
||||||
|
data: {
|
||||||
|
username,
|
||||||
|
discriminator,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.testers.set(app.user.id, {
|
||||||
|
state: app.state,
|
||||||
|
user: this.client.users._add(app.user),
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete user from this application's allowlist.
|
||||||
|
* @param {UserResolvable} user User
|
||||||
|
* @returns {Promise<DeveloperPortalApplication>}
|
||||||
|
*/
|
||||||
|
async deleteTester(user) {
|
||||||
|
const userId = this.client.users.resolveId(user);
|
||||||
|
await this.client.api.applications[this.id].allowlist[userId].delete();
|
||||||
|
this.testers.delete(userId);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The data for editing a application.
|
||||||
|
* @typedef {Object} ApplicationEditData
|
||||||
|
* @property {string} [name] The name of the app
|
||||||
|
* @property {string} [description] The description of the app
|
||||||
|
* @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon of the app
|
||||||
|
* @property {?(BufferResolvable|Base64Resolvable)} [cover] The application's default rich presence invite
|
||||||
|
* @property {boolean} [botPublic] When false only app owner can join the app's bot to guilds
|
||||||
|
* @property {boolean} [botRequireCodeGrant] When true the app's bot will only join upon completion of the full oauth2 code grant flow
|
||||||
|
* @property {?string} [TermsOfService] ToS URL
|
||||||
|
* @property {?string} [PrivacyPolicy] Privacy policy URL
|
||||||
|
* @property {number} [flags] The application's public flags
|
||||||
|
* @property {Array<string>} [redirectURIs] Redirect URIs (OAuth2 only)
|
||||||
|
* @property {Array<string>} [tags] Up to 5 tags describing the content and functionality of the application
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Edits this application.
|
||||||
|
* @param {ApplicationEditData} data Edit data for the application
|
||||||
|
* @returns {Promise<DeveloperPortalApplication>}
|
||||||
|
*/
|
||||||
|
async edit(data) {
|
||||||
|
const _data = {};
|
||||||
|
if (data.name) _data.name = data.name;
|
||||||
|
if (typeof data.icon !== 'undefined') {
|
||||||
|
_data.icon = await DataResolver.resolveImage(data.icon);
|
||||||
|
}
|
||||||
|
if (data.description) _data.description = data.description;
|
||||||
|
if (typeof data.cover !== 'undefined') {
|
||||||
|
_data.cover = await DataResolver.resolveImage(data.cover);
|
||||||
|
}
|
||||||
|
if (data.botPublic) _data.bot_public = data.botPublic;
|
||||||
|
if (data.botRequireCodeGrant) _data.bot_require_code_grant = data.botRequireCodeGrant;
|
||||||
|
if (data.TermsOfService) _data.terms_of_service_url = data.TermsOfService;
|
||||||
|
if (data.PrivacyPolicy) _data.privacy_policy_url = data.PrivacyPolicy;
|
||||||
|
if (data.flags) _data.flags = data.flags;
|
||||||
|
if (data.redirectURIs) _data.redirect_uris = data.redirectURIs;
|
||||||
|
if (data.tags) _data.tags = data.tags;
|
||||||
|
//
|
||||||
|
const app = await this.client.api.applications[this.id].patch({ data: _data });
|
||||||
|
this._patch(app);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new bot for this application.
|
||||||
|
* @returns {Promise<DeveloperPortalApplication>}
|
||||||
|
*/
|
||||||
|
async createBot() {
|
||||||
|
if (this.bot) throw new Error('Application already has a bot.');
|
||||||
|
await this.client.api.applications[this.id].bot.post();
|
||||||
|
const app = await this.fetch();
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset CLient Secret for this application.
|
||||||
|
* @param {number} MFACode The MFA code (if required)
|
||||||
|
* @returns {Promise<string>}
|
||||||
|
*/
|
||||||
|
async resetClientSecret(MFACode) {
|
||||||
|
const app = MFACode
|
||||||
|
? await this.client.api.applications[this.id].reset.post({
|
||||||
|
data: {
|
||||||
|
code: MFACode,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
: await this.client.api.applications[this.id].reset.post();
|
||||||
|
return app.secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset Bot Token for this application.
|
||||||
|
* @param {number} MFACode The MFA code (if required)
|
||||||
|
* @returns {Promise<string>}
|
||||||
|
*/
|
||||||
|
async resetBotToken(MFACode) {
|
||||||
|
const app = MFACode
|
||||||
|
? await this.client.api.applications[this.id].bot.reset.post({
|
||||||
|
data: {
|
||||||
|
code: MFACode,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
: await this.client.api.applications[this.id].bot.reset.post();
|
||||||
|
return app.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes this application.
|
||||||
|
* @param {number} MFACode The MFA code (if required)
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
delete(MFACode) {
|
||||||
|
return this.client.developerPortal.deleteApplication(this.id, MFACode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new image to this application. (RPC)
|
||||||
|
* @param {BufferResolvable|Base64Resolvable} image Image Resolvable
|
||||||
|
* @param {string} name Name of the image
|
||||||
|
* @returns {ApplicationAsset}
|
||||||
|
*/
|
||||||
|
async addAsset(image, name) {
|
||||||
|
const data = await DataResolver.resolveImage(image);
|
||||||
|
const asset = await this.client.api.applications[this.id].assets.post({
|
||||||
|
data: {
|
||||||
|
type: 1,
|
||||||
|
name,
|
||||||
|
image: data,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
id: asset.id,
|
||||||
|
name: asset.name,
|
||||||
|
type: AssetTypes[asset.type - 1],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an image from this application. (RPC)
|
||||||
|
* @param {Snowflake} id ID of the image
|
||||||
|
* @returns {Promise<undefined>}
|
||||||
|
*/
|
||||||
|
async deleteAsset(id) {
|
||||||
|
await this.client.api.applications[this.id].assets[id].delete();
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When concatenated with a string, this automatically returns the application's name instead of the
|
||||||
|
* Application object.
|
||||||
|
* @returns {?string}
|
||||||
|
* @example
|
||||||
|
* // Logs: Application name: My App
|
||||||
|
* console.log(`Application name: ${application}`);
|
||||||
|
*/
|
||||||
|
toString() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
toJSON() {
|
||||||
|
return super.toJSON({ createdTimestamp: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = DeveloperPortalApplication;
|
@ -980,6 +980,7 @@ exports.VerificationLevels = createEnum(['NONE', 'LOW', 'MEDIUM', 'HIGH', 'VERY_
|
|||||||
* * MAXIMUM_PINS
|
* * MAXIMUM_PINS
|
||||||
* * MAXIMUM_RECIPIENTS
|
* * MAXIMUM_RECIPIENTS
|
||||||
* * MAXIMUM_ROLES
|
* * MAXIMUM_ROLES
|
||||||
|
* * MAXIMUM_USERNAMES
|
||||||
* * MAXIMUM_WEBHOOKS
|
* * MAXIMUM_WEBHOOKS
|
||||||
* * MAXIMUM_EMOJIS
|
* * MAXIMUM_EMOJIS
|
||||||
* * MAXIMUM_REACTIONS
|
* * MAXIMUM_REACTIONS
|
||||||
@ -1050,6 +1051,7 @@ exports.VerificationLevels = createEnum(['NONE', 'LOW', 'MEDIUM', 'HIGH', 'VERY_
|
|||||||
* * INSUFFICIENT_BOOSTS
|
* * INSUFFICIENT_BOOSTS
|
||||||
* * INVALID_JSON
|
* * INVALID_JSON
|
||||||
* * TWO_FACTOR_REQUIRED
|
* * TWO_FACTOR_REQUIRED
|
||||||
|
* * INVALID_TWO_FACTOR_CODE
|
||||||
* * NO_USERS_WITH_DISCORDTAG_EXIST
|
* * NO_USERS_WITH_DISCORDTAG_EXIST
|
||||||
* * REACTION_BLOCKED
|
* * REACTION_BLOCKED
|
||||||
* * RESOURCE_OVERLOADED
|
* * RESOURCE_OVERLOADED
|
||||||
@ -1128,6 +1130,7 @@ exports.APIErrors = {
|
|||||||
MAXIMUM_PINS: 30003,
|
MAXIMUM_PINS: 30003,
|
||||||
MAXIMUM_RECIPIENTS: 30004,
|
MAXIMUM_RECIPIENTS: 30004,
|
||||||
MAXIMUM_ROLES: 30005,
|
MAXIMUM_ROLES: 30005,
|
||||||
|
MAXIMUN_USERNAMES: 30006,
|
||||||
MAXIMUM_WEBHOOKS: 30007,
|
MAXIMUM_WEBHOOKS: 30007,
|
||||||
MAXIMUM_EMOJIS: 30008,
|
MAXIMUM_EMOJIS: 30008,
|
||||||
MAXIMUM_REACTIONS: 30010,
|
MAXIMUM_REACTIONS: 30010,
|
||||||
@ -1199,6 +1202,7 @@ exports.APIErrors = {
|
|||||||
INSUFFICIENT_BOOSTS: 50101,
|
INSUFFICIENT_BOOSTS: 50101,
|
||||||
INVALID_JSON: 50109,
|
INVALID_JSON: 50109,
|
||||||
TWO_FACTOR_REQUIRED: 60003,
|
TWO_FACTOR_REQUIRED: 60003,
|
||||||
|
INVALID_TWO_FACTOR_CODE: 60008,
|
||||||
NO_USERS_WITH_DISCORDTAG_EXIST: 80004,
|
NO_USERS_WITH_DISCORDTAG_EXIST: 80004,
|
||||||
REACTION_BLOCKED: 90001,
|
REACTION_BLOCKED: 90001,
|
||||||
RESOURCE_OVERLOADED: 130000,
|
RESOURCE_OVERLOADED: 130000,
|
||||||
|
75
typings/index.d.ts
vendored
75
typings/index.d.ts
vendored
@ -319,6 +319,77 @@ export abstract class Application extends Base {
|
|||||||
public toString(): string | null;
|
public toString(): string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Tester {
|
||||||
|
state: number;
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApplicationEditData {
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
icon?: BufferResolvable | Base64Resolvable;
|
||||||
|
cover?: BufferResolvable | Base64Resolvable;
|
||||||
|
botPublic?: boolean;
|
||||||
|
botRequireCodeGrant?: boolean;
|
||||||
|
TermsOfService?: string;
|
||||||
|
PrivacyPolicy?: string;
|
||||||
|
flags?: number;
|
||||||
|
redirectURIs?: string[];
|
||||||
|
tags?: string[];
|
||||||
|
}
|
||||||
|
export class DeveloperPortalApplication extends Base {
|
||||||
|
private constructor(client: Client, data: object);
|
||||||
|
public botPublic: boolean | null;
|
||||||
|
public botRequireCodeGrant: boolean | null;
|
||||||
|
public commands: ApplicationCommandManager;
|
||||||
|
public cover: string | null;
|
||||||
|
public flags: Readonly<ApplicationFlags>;
|
||||||
|
public tags: string[];
|
||||||
|
public installParams: ClientApplicationInstallParams | null;
|
||||||
|
public customInstallURL: string | null;
|
||||||
|
public owner: User | Team | null;
|
||||||
|
public readonly partial: boolean;
|
||||||
|
public rpcOrigins: string[];
|
||||||
|
public readonly createdAt: Date;
|
||||||
|
public readonly createdTimestamp: number;
|
||||||
|
public description: string | null;
|
||||||
|
public icon: string | null;
|
||||||
|
public id: Snowflake;
|
||||||
|
public name: string | null;
|
||||||
|
public redirectURIs: string[];
|
||||||
|
public interactionEndpointURL: string | null;
|
||||||
|
public publicKey: string;
|
||||||
|
public testers: Collection<Snowflake, Tester>;
|
||||||
|
public TermsOfService: string | null;
|
||||||
|
public PrivacyPolicy: string | null;
|
||||||
|
public fetch(): Promise<ClientApplication>;
|
||||||
|
public coverURL(options?: StaticImageURLOptions): string | null;
|
||||||
|
/** @deprecated This method is deprecated as it is unsupported and will be removed in the next major version. */
|
||||||
|
public fetchAssets(): Promise<ApplicationAsset[]>;
|
||||||
|
public iconURL(options?: StaticImageURLOptions): string | null;
|
||||||
|
public toJSON(): unknown;
|
||||||
|
public toString(): string | null;
|
||||||
|
public fetchTesters(): Promise<this>;
|
||||||
|
public addTester(username: string, discriminator: string): Promise<DeveloperPortalApplication>;
|
||||||
|
public deleteTester(user: UserResolvable): Promise<DeveloperPortalApplication>;
|
||||||
|
public edit(data: ApplicationEditData): Promise<DeveloperPortalApplication>;
|
||||||
|
public createBot(): Promise<DeveloperPortalApplication>;
|
||||||
|
public resetClientSecret(MFACode?: number): Promise<string>;
|
||||||
|
public resetBotToken(MFACode?: number): Promise<string>;
|
||||||
|
public delete(MFACode?: number): Promise<undefined>;
|
||||||
|
public addAsset(image: BufferResolvable | Base64Resolvable, name: string): Promise<ApplicationAsset>;
|
||||||
|
public deleteAsset(id: string): Promise<undefined>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DeveloperPortalManager extends BaseManager {
|
||||||
|
constructor(client: Client);
|
||||||
|
public applications: Collection<Snowflake, DeveloperPortalApplication>;
|
||||||
|
public teams: Collection<Snowflake, Team>;
|
||||||
|
public fetch(): Promise<DeveloperPortalManager>;
|
||||||
|
public createApplication(name: string, teamId?: Team | Snowflake): Promise<DeveloperPortalApplication>;
|
||||||
|
public deleteApplication(id: Snowflake, MFACode?: number): Promise<undefined>;
|
||||||
|
}
|
||||||
|
|
||||||
export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
||||||
private constructor(client: Client, data: RawApplicationCommandData, guild?: Guild, guildId?: Snowflake);
|
private constructor(client: Client, data: RawApplicationCommandData, guild?: Guild, guildId?: Snowflake);
|
||||||
public applicationId: Snowflake;
|
public applicationId: Snowflake;
|
||||||
@ -3416,7 +3487,7 @@ export class ChannelManager extends CachedManager<Snowflake, AnyChannel, Channel
|
|||||||
|
|
||||||
export type FetchGuildApplicationCommandFetchOptions = Omit<FetchApplicationCommandOptions, 'guildId'>;
|
export type FetchGuildApplicationCommandFetchOptions = Omit<FetchApplicationCommandOptions, 'guildId'>;
|
||||||
|
|
||||||
export class ClientUserSettingManager {
|
export class ClientUserSettingManager extends BaseManager {
|
||||||
private constructor(client: Client);
|
private constructor(client: Client);
|
||||||
public rawSetting: RawUserSettingsData | object;
|
public rawSetting: RawUserSettingsData | object;
|
||||||
public locale: localeSetting | null;
|
public locale: localeSetting | null;
|
||||||
@ -3993,6 +4064,7 @@ export interface APIErrors {
|
|||||||
MAXIMUM_PINS: 30003;
|
MAXIMUM_PINS: 30003;
|
||||||
MAXIMUM_RECIPIENTS: 30004;
|
MAXIMUM_RECIPIENTS: 30004;
|
||||||
MAXIMUM_ROLES: 30005;
|
MAXIMUM_ROLES: 30005;
|
||||||
|
MAXIMUM_USERNAMES: 30006;
|
||||||
MAXIMUM_WEBHOOKS: 30007;
|
MAXIMUM_WEBHOOKS: 30007;
|
||||||
MAXIMUM_EMOJIS: 30008;
|
MAXIMUM_EMOJIS: 30008;
|
||||||
MAXIMUM_REACTIONS: 30010;
|
MAXIMUM_REACTIONS: 30010;
|
||||||
@ -4064,6 +4136,7 @@ export interface APIErrors {
|
|||||||
INSUFFICIENT_BOOSTS: 50101;
|
INSUFFICIENT_BOOSTS: 50101;
|
||||||
INVALID_JSON: 50109;
|
INVALID_JSON: 50109;
|
||||||
TWO_FACTOR_REQUIRED: 60003;
|
TWO_FACTOR_REQUIRED: 60003;
|
||||||
|
INVALID_TWO_FACTOR_CODE: 60008;
|
||||||
NO_USERS_WITH_DISCORDTAG_EXIST: 80004;
|
NO_USERS_WITH_DISCORDTAG_EXIST: 80004;
|
||||||
REACTION_BLOCKED: 90001;
|
REACTION_BLOCKED: 90001;
|
||||||
RESOURCE_OVERLOADED: 130000;
|
RESOURCE_OVERLOADED: 130000;
|
||||||
|
Loading…
Reference in New Issue
Block a user