This commit is contained in:
March 7th 2022-05-06 22:25:27 +07:00
parent efe416340d
commit 95cc955da9
7 changed files with 75 additions and 36 deletions

1
discord.js/main.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -14,8 +14,8 @@
"format": "prettier --write src/**/*.js typings/**/*.ts", "format": "prettier --write src/**/*.js typings/**/*.ts",
"lint:all": "npm run lint && npm run lint:typings", "lint:all": "npm run lint && npm run lint:typings",
"checkup": "node update.mjs", "checkup": "node update.mjs",
"docs": "docgen --source src --custom docs/index.yml --output docs/docs.json", "docs": "docgen --source src --custom discord.js/index.yml --output discord.js/main.json",
"docs:test": "docgen --source src --custom docs/index.yml" "docs:test": "docgen --source src --custom discord.js/index.yml"
}, },
"files": [ "files": [
"src", "src",

View File

@ -3,7 +3,7 @@
const { Collection } = require('@discordjs/collection'); const { Collection } = require('@discordjs/collection');
const User = require('./User'); const User = require('./User');
const { Util } = require('..'); const { Util } = require('..');
const { HypeSquadOptions, Opcodes } = require('../util/Constants'); const { HypeSquadOptions, Opcodes, NitroState } = require('../util/Constants');
const DataResolver = require('../util/DataResolver'); const DataResolver = require('../util/DataResolver');
/** /**
@ -17,6 +17,10 @@ class ClientUser extends User {
/* /*
Add: notes Add: notes
*/ */
/**
* The notes cache of the client user.
* @type {Collection<Snowflake, Message>}
*/
this.notes = new Collection(); this.notes = new Collection();
// This.messageMentions = new Collection(); // This.messageMentions = new Collection();
@ -41,15 +45,11 @@ class ClientUser extends User {
if ('token' in data) this.client.token = data.token; if ('token' in data) this.client.token = data.token;
// Add (Selfbot) // Add (Selfbot)
if ('premium' in data) this.nitro = data.premium; if ('premium' in data) this.nitro = NitroState[data.premium];
/** /**
* Nitro Status * Nitro Status
* `0`: None * @type {NitroState}
* `1`: Classic * @see https://discord.com/developers/docs/resources/user#user-object-premium-types
* `2`: Boost
* @external
* https://discord.com/developers/docs/resources/user#user-object-premium-types
* @type {Number}
*/ */
if ('purchased_flags' in data) this.nitroType = data.purchased_flags; if ('purchased_flags' in data) this.nitroType = data.purchased_flags;
if ('phone' in data) this.phoneNumber = data.phone; if ('phone' in data) this.phoneNumber = data.phone;

View File

@ -6,8 +6,37 @@ const hiddenCharter =
const { RangeError } = require('../errors'); const { RangeError } = require('../errors');
const Util = require('../util/Util'); const Util = require('../util/Util');
/**
* Send Embedlink to Discord
*/
class WebEmbed { class WebEmbed {
constructor(data = {}) { constructor(data = {}) {
/**
* A `Partial` object is a representation of any existing object.
* This object contains between 0 and all of the original objects parameters.
* This is true regardless of whether the parameters are optional in the base object.
* @typedef {Object} Partial
*/
/**
* Represents the possible options for a WebEmbed
* @typedef {Object} WebEmbedOptions
* @property {string} [title] The title of this embed
* @property {string} [description] The description of this embed
* @property {string} [url] The URL of this embed
* @property {ColorResolvable} [color] The color of this embed
* @property {Partial<WebEmbedAuthor>} [author] The author of this embed
* @property {Partial<WebEmbedThumbnail>} [thumbnail] The thumbnail of this embed
* @property {Partial<WebEmbedImage>} [image] The image of this embed
* @property {Partial<WebEmbedVideo>} [video] The video of this embed
* @property {Partial<WebEmbedFooter>} [footer] The footer of this embed
* @property {Partial<WebEmbedProvider>} [provider] The provider of this embed
*/
// eslint-disable-next-line valid-jsdoc
/**
* @param {WebEmbed|WebEmbedOptions|APIEmbed} [data={}] WebEmbed to clone or raw embed data
*/
this._setup(data); this._setup(data);
/** /**
* Shorten the link * Shorten the link
@ -56,8 +85,8 @@ class WebEmbed {
this.color = 'color' in data ? Util.resolveColor(data.color) : null; this.color = 'color' in data ? Util.resolveColor(data.color) : null;
/** /**
* Represents the image of a MessageEmbed * Represents the image of a WebEmbed
* @typedef {Object} MessageEmbedImage * @typedef {Object} WebEmbedImage
* @property {string} url URL for this image * @property {string} url URL for this image
* @property {string} proxyURL ProxyURL for this image * @property {string} proxyURL ProxyURL for this image
* @property {number} height Height of this image * @property {number} height Height of this image
@ -66,7 +95,7 @@ class WebEmbed {
/** /**
* The image of this embed, if there is one * The image of this embed, if there is one
* @type {?MessageEmbedImage} * @type {?WebEmbedImage}
*/ */
this.image = data.image this.image = data.image
? { ? {
@ -79,7 +108,7 @@ class WebEmbed {
/** /**
* The thumbnail of this embed (if there is one) * The thumbnail of this embed (if there is one)
* @type {?MessageEmbedThumbnail} * @type {?WebEmbedThumbnail}
*/ */
this.thumbnail = data.thumbnail this.thumbnail = data.thumbnail
? { ? {
@ -91,8 +120,8 @@ class WebEmbed {
: null; : null;
/** /**
* Represents the video of a MessageEmbed * Represents the video of a WebEmbed
* @typedef {Object} MessageEmbedVideo * @typedef {Object} WebEmbedVideo
* @property {string} url URL of this video * @property {string} url URL of this video
* @property {string} proxyURL ProxyURL for this video * @property {string} proxyURL ProxyURL for this video
* @property {number} height Height of this video * @property {number} height Height of this video
@ -101,7 +130,7 @@ class WebEmbed {
/** /**
* The video of this embed (if there is one) * The video of this embed (if there is one)
* @type {?MessageEmbedVideo} * @type {?WebEmbedVideo}
* @readonly * @readonly
*/ */
this.video = data.video this.video = data.video
@ -114,8 +143,8 @@ class WebEmbed {
: null; : null;
/** /**
* Represents the author field of a MessageEmbed * Represents the author field of a WebEmbed
* @typedef {Object} MessageEmbedAuthor * @typedef {Object} WebEmbedAuthor
* @property {string} name The name of this author * @property {string} name The name of this author
* @property {string} url URL of this author * @property {string} url URL of this author
* @property {string} iconURL URL of the icon for this author * @property {string} iconURL URL of the icon for this author
@ -124,7 +153,7 @@ class WebEmbed {
/** /**
* The author of this embed (if there is one) * The author of this embed (if there is one)
* @type {?MessageEmbedAuthor} * @type {?WebEmbedAuthor}
*/ */
this.author = data.author this.author = data.author
? { ? {
@ -134,15 +163,15 @@ class WebEmbed {
: null; : null;
/** /**
* Represents the provider of a MessageEmbed * Represents the provider of a WebEmbed
* @typedef {Object} MessageEmbedProvider * @typedef {Object} WebEmbedProvider
* @property {string} name The name of this provider * @property {string} name The name of this provider
* @property {string} url URL of this provider * @property {string} url URL of this provider
*/ */
/** /**
* The provider of this embed (if there is one) * The provider of this embed (if there is one)
* @type {?MessageEmbedProvider} * @type {?WebEmbedProvider}
*/ */
this.provider = data.provider this.provider = data.provider
? { ? {
@ -152,7 +181,7 @@ class WebEmbed {
: null; : null;
} }
/** /**
* The options to provide for setting an author for a {@link MessageEmbed}. * The options to provide for setting an author for a {@link WebEmbed}.
* @typedef {Object} EmbedAuthorData * @typedef {Object} EmbedAuthorData
* @property {string} name The name of this author. * @property {string} name The name of this author.
*/ */
@ -161,7 +190,7 @@ class WebEmbed {
* Sets the author of this embed. * Sets the author of this embed.
* @param {string|EmbedAuthorData|null} options The options to provide for the author. * @param {string|EmbedAuthorData|null} options The options to provide for the author.
* Provide `null` to remove the author data. * Provide `null` to remove the author data.
* @returns {MessageEmbed} * @returns {WebEmbed}
*/ */
setAuthor(options) { setAuthor(options) {
if (options === null) { if (options === null) {
@ -177,7 +206,7 @@ class WebEmbed {
} }
/** /**
* The options to provide for setting an provider for a {@link MessageEmbed}. * The options to provide for setting an provider for a {@link WebEmbed}.
* @typedef {Object} EmbedProviderData * @typedef {Object} EmbedProviderData
* @property {string} name The name of this provider. * @property {string} name The name of this provider.
*/ */
@ -186,7 +215,7 @@ class WebEmbed {
* Sets the provider of this embed. * Sets the provider of this embed.
* @param {string|EmbedProviderData|null} options The options to provide for the provider. * @param {string|EmbedProviderData|null} options The options to provide for the provider.
* Provide `null` to remove the provider data. * Provide `null` to remove the provider data.
* @returns {MessageEmbed} * @returns {WebEmbed}
*/ */
setProvider(options) { setProvider(options) {
if (options === null) { if (options === null) {
@ -204,7 +233,7 @@ class WebEmbed {
/** /**
* Sets the color of this embed. * Sets the color of this embed.
* @param {ColorResolvable} color The color of the embed * @param {ColorResolvable} color The color of the embed
* @returns {MessageEmbed} * @returns {WebEmbed}
*/ */
setColor(color) { setColor(color) {
this.color = Util.resolveColor(color); this.color = Util.resolveColor(color);
@ -214,7 +243,7 @@ class WebEmbed {
/** /**
* Sets the description of this embed. * Sets the description of this embed.
* @param {string} description The description (Limit 350 characters) * @param {string} description The description (Limit 350 characters)
* @returns {MessageEmbed} * @returns {WebEmbed}
*/ */
setDescription(description) { setDescription(description) {
this.description = Util.verifyString(description, RangeError, 'EMBED_DESCRIPTION'); this.description = Util.verifyString(description, RangeError, 'EMBED_DESCRIPTION');
@ -224,7 +253,7 @@ class WebEmbed {
/** /**
* Sets the image of this embed. * Sets the image of this embed.
* @param {string} url The URL of the image * @param {string} url The URL of the image
* @returns {MessageEmbed} * @returns {WebEmbed}
*/ */
setImage(url) { setImage(url) {
if (this.thumbnail && this.thumbnail.url) { if (this.thumbnail && this.thumbnail.url) {
@ -239,7 +268,7 @@ class WebEmbed {
/** /**
* Sets the thumbnail of this embed. * Sets the thumbnail of this embed.
* @param {string} url The URL of the image * @param {string} url The URL of the image
* @returns {MessageEmbed} * @returns {WebEmbed}
*/ */
setThumbnail(url) { setThumbnail(url) {
if (this.image && this.image.url) { if (this.image && this.image.url) {
@ -254,7 +283,7 @@ class WebEmbed {
/** /**
* Sets the video of this embed. * Sets the video of this embed.
* @param {string} url The URL of the video * @param {string} url The URL of the video
* @returns {MessageEmbed} * @returns {WebEmbed}
*/ */
setVideo(url) { setVideo(url) {
this.video = { url }; this.video = { url };
@ -264,7 +293,7 @@ class WebEmbed {
/** /**
* Sets the title of this embed. * Sets the title of this embed.
* @param {string} title The title * @param {string} title The title
* @returns {MessageEmbed} * @returns {WebEmbed}
*/ */
setTitle(title) { setTitle(title) {
this.title = Util.verifyString(title, RangeError, 'EMBED_TITLE'); this.title = Util.verifyString(title, RangeError, 'EMBED_TITLE');
@ -274,7 +303,7 @@ class WebEmbed {
/** /**
* Sets the URL of this embed. * Sets the URL of this embed.
* @param {string} url The URL * @param {string} url The URL
* @returns {MessageEmbed} * @returns {WebEmbed}
*/ */
setURL(url) { setURL(url) {
this.url = url; this.url = url;

View File

@ -30,6 +30,12 @@ const listUserAgent = [
'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_3_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 Edg/100.0.1185.39', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_3_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 Edg/100.0.1185.39',
]; ];
exports.NitroState = {
0: 'NONE',
1: 'CLASSIC',
2: 'BOOST',
};
exports.DMScanLevel = { exports.DMScanLevel = {
0: 'NOT_SCAN', 0: 'NOT_SCAN',
1: 'NOT_FRIEND', 1: 'NOT_FRIEND',

View File

@ -34,6 +34,9 @@ const JSONBig = require('json-bigint');
* @property {number|number[]|string} [shards] The shard's id to run, or an array of shard ids. If not specified, * @property {number|number[]|string} [shards] The shard's id to run, or an array of shard ids. If not specified,
* the client will spawn {@link ClientOptions#shardCount} shards. If set to `auto`, it will fetch the * the client will spawn {@link ClientOptions#shardCount} shards. If set to `auto`, it will fetch the
* recommended amount of shards from Discord and spawn that amount * recommended amount of shards from Discord and spawn that amount
* @property {boolean} [checkUpdate=true] Check for module updates at startup
* @property {boolean} [readyStatus=true] Sync state with Discord Client
* @property {boolean} [autoCookie=true] Automatically add Cookies to Request on startup
* @property {number} [shardCount=1] The total amount of shards used by all processes of this bot * @property {number} [shardCount=1] The total amount of shards used by all processes of this bot
* (e.g. recommended shard count, shard count of the ShardingManager) * (e.g. recommended shard count, shard count of the ShardingManager)
* @property {CacheFactory} [makeCache] Function to create a cache. * @property {CacheFactory} [makeCache] Function to create a cache.
@ -49,7 +52,7 @@ const JSONBig = require('json-bigint');
* @property {number} [invalidRequestWarningInterval=0] The number of invalid REST requests (those that return * @property {number} [invalidRequestWarningInterval=0] The number of invalid REST requests (those that return
* 401, 403, or 429) in a 10 minute window between emitted warnings (0 for no warnings). That is, if set to 500, * 401, 403, or 429) in a 10 minute window between emitted warnings (0 for no warnings). That is, if set to 500,
* warnings will be emitted at invalid request number 500, 1000, 1500, and so on. * warnings will be emitted at invalid request number 500, 1000, 1500, and so on.
* @property {PartialType[]} [partials] Structures allowed to be partial. This means events can be emitted even when * @property {PartialType[]} [partials=['USER', 'CHANNEL', 'GUILD_MEMBER', 'MESSAGE', 'REACTION', 'GUILD_SCHEDULED_EVENT']] Structures allowed to be partial. This means events can be emitted even when
* they're missing all the data for a particular structure. See the "Partial Structures" topic on the * they're missing all the data for a particular structure. See the "Partial Structures" topic on the
* [guide](https://discordjs.guide/popular-topics/partials.html) for some * [guide](https://discordjs.guide/popular-topics/partials.html) for some
* important usage information, as partials require you to put checks in place when handling data. * important usage information, as partials require you to put checks in place when handling data.
@ -72,7 +75,7 @@ const JSONBig = require('json-bigint');
* @property {string[]} [userAgentSuffix] An array of additional bot info to be appended to the end of the required * @property {string[]} [userAgentSuffix] An array of additional bot info to be appended to the end of the required
* [User Agent](https://discord.com/developers/docs/reference#user-agent) header * [User Agent](https://discord.com/developers/docs/reference#user-agent) header
* @property {PresenceData} [presence={}] Presence data to use upon login * @property {PresenceData} [presence={}] Presence data to use upon login
* @property {IntentsResolvable} intents Intents to enable for this connection * @property {IntentsResolvable} [intents] Intents to enable for this connection
* @property {number} [waitGuildTimeout=15_000] Time in milliseconds that Clients with the GUILDS intent should wait for * @property {number} [waitGuildTimeout=15_000] Time in milliseconds that Clients with the GUILDS intent should wait for
* missing guilds to be recieved before starting the bot. If not specified, the default is 15 seconds. * missing guilds to be recieved before starting the bot. If not specified, the default is 15 seconds.
* @property {SweeperOptions} [sweepers={}] Options for cache sweeping * @property {SweeperOptions} [sweepers={}] Options for cache sweeping