1.3.1
- Update Document - Fix WebEmbed - Fix MessagePayload - Clear warn "Accessing non-existent property inside a circular dependency" (Pull #26)
This commit is contained in:
parent
5caadfe8da
commit
8688dbac8c
@ -4,6 +4,11 @@
|
|||||||
# <strong>[Risky actions](https://github.com/Merubokkusu/Discord-S.C.U.M/issues/66)</strong>
|
# <strong>[Risky actions](https://github.com/Merubokkusu/Discord-S.C.U.M/issues/66)</strong>
|
||||||
|
|
||||||
# Quick links
|
# Quick links
|
||||||
|
- [<strong>ClientOption</strong>](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/ClientOption.md)
|
||||||
|
- [<strong>HTTPOption</strong>](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/HTTPOption.md)
|
||||||
|
- [<strong>Guild</strong>](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/Guild.md)
|
||||||
|
- [<strong>Message</strong>](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/Message.md)
|
||||||
|
- [<strong>User</strong>](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/User.md)
|
||||||
|
|
||||||
## More features
|
## More features
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# Quick Links
|
||||||
|
- [Client Option](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/ClientOption.md#client-settings)
|
||||||
|
- [Client Functions](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/ClientOption.md#client-functions)
|
||||||
|
|
||||||
## Client Settings
|
## Client Settings
|
||||||
```js
|
```js
|
||||||
new Client({
|
new Client({
|
||||||
@ -6,3 +10,13 @@ new Client({
|
|||||||
autoCookie: true, // Auto added Cookie and Fingerprint [Enable Default](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/DOCUMENT.md#http-options)
|
autoCookie: true, // Auto added Cookie and Fingerprint [Enable Default](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/DOCUMENT.md#http-options)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Client Functions
|
||||||
|
- Update Cookie and Fingerprint
|
||||||
|
```js
|
||||||
|
client.updateCookie(): Promise<void>
|
||||||
|
```
|
||||||
|
- Reddem Nitro
|
||||||
|
```js
|
||||||
|
client.reddemNitro('code'): Promise<void>
|
||||||
|
```
|
@ -1,3 +1,9 @@
|
|||||||
|
# Quick Links:
|
||||||
|
- [Set Guild Folder and Position](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/Guild.md#discord-guild-set-position)
|
||||||
|
- [DM group](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/Guild.md#group-dm)
|
||||||
|
- [Join Guild](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/Guild.md#join-guild-using-invite)
|
||||||
|
- [Community](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/Guild.md#set-community))
|
||||||
|
|
||||||
## Discord Guild set position
|
## Discord Guild set position
|
||||||
<details>
|
<details>
|
||||||
<summary><strong>Click to show</strong></summary>
|
<summary><strong>Click to show</strong></summary>
|
||||||
@ -64,3 +70,16 @@ await client.fetchInvite('code').then(async invite => {
|
|||||||
|
|
||||||
<strong>But if you are blocked by HCaptcha, this will not work</strong>
|
<strong>But if you are blocked by HCaptcha, this will not work</strong>
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
## Set Community
|
||||||
|
<details>
|
||||||
|
<summary>Click to show</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
await guild.setCommunity(stats: boolean, publicUpdatesChannel: TextChannelResolvable, rulesChannel: TextChannelResolvable, reason?: string): Promise<Guild>;
|
||||||
|
// Enable with default
|
||||||
|
await guild.setCommunity(true);
|
||||||
|
// Disable
|
||||||
|
await guild.setCommunity(false);
|
||||||
|
```
|
||||||
|
</details>
|
@ -1,5 +1,5 @@
|
|||||||
## HTTP options:
|
## HTTP options:
|
||||||
|
- Change API v9 to v10
|
||||||
```js
|
```js
|
||||||
/* If you want to change the API version from v9 to v10, here are the instructions */
|
/* If you want to change the API version from v9 to v10, here are the instructions */
|
||||||
const { Client } = require('discord.js-selfbot-v13');
|
const { Client } = require('discord.js-selfbot-v13');
|
||||||
@ -14,9 +14,4 @@ const client = new Client({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/* Discord fingerprint ??? idk ... */
|
|
||||||
/**
|
|
||||||
* const { data } = await axios.get('https://discord.com/api/v9/experiments');
|
|
||||||
* client.options.http.header['x-fingerprint'] = data.fingerprint
|
|
||||||
*/
|
|
||||||
```
|
```
|
@ -1,3 +1,7 @@
|
|||||||
|
# Quick Links:
|
||||||
|
- [Interaction](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/Message.md#interaction)
|
||||||
|
- [Embed](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/Message.md#messageembed-)
|
||||||
|
|
||||||
## Interaction
|
## Interaction
|
||||||
<details>
|
<details>
|
||||||
<summary>Button Click</summary>
|
<summary>Button Click</summary>
|
||||||
@ -86,8 +90,9 @@ message.channel.send({ content: `Hello world`, embeds: [w] }) // Patched :)
|
|||||||
|
|
||||||
```
|
```
|
||||||
### Features & Issues
|
### Features & Issues
|
||||||
- No Timestamp, Footer, Thumbnail (but embed video, thumbnail working), Fields, Author iconURL
|
- No Timestamp, Footer, Fields, Author iconURL
|
||||||
- Video with Embed working
|
- Video with Embed working
|
||||||
|
- Can only choose between image and thumbnail
|
||||||
- Description limit 350 characters
|
- Description limit 350 characters
|
||||||
- If you use hidden mode you must make sure your custom content is less than 1000 characters without nitro (because hidden mode uses 1000 characters + URL)
|
- If you use hidden mode you must make sure your custom content is less than 1000 characters without nitro (because hidden mode uses 1000 characters + URL)
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
# Quick Links:
|
||||||
|
- [Setting](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/User.md#user-settings)
|
||||||
|
- [User Info](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/User.md#discord-user-info)
|
||||||
|
- [Relationship](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/User.md#discord-user-friend--blocked)
|
||||||
|
- [Rich Presence](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/User.md#custom-status-and-rpc)
|
||||||
|
- [Other](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/User.md#user--clientuser-method)
|
||||||
|
|
||||||
## User Settings
|
## User Settings
|
||||||
<details>
|
<details>
|
||||||
<summary><strong>Click to show</strong></summary>
|
<summary><strong>Click to show</strong></summary>
|
||||||
@ -221,15 +228,7 @@ await client.user.setPassword('old password', 'new password');
|
|||||||
await client.user.disableAccount('password');
|
await client.user.disableAccount('password');
|
||||||
// Delete Account [WARNING] Cannot be changed once used!
|
// Delete Account [WARNING] Cannot be changed once used!
|
||||||
await client.user.deleteAccount('password');
|
await client.user.deleteAccount('password');
|
||||||
```
|
// Reddem Nitro
|
||||||
</details>
|
|
||||||
|
|
||||||
|
|
||||||
## Reddem Nitro ?
|
|
||||||
<details>
|
|
||||||
<summary>Click to show</summary>
|
|
||||||
|
|
||||||
```js
|
|
||||||
await client.reddemNitro('code')
|
await client.reddemNitro('code')
|
||||||
```
|
```
|
||||||
</details>
|
</details>
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord.js-selfbot-v13",
|
"name": "discord.js-selfbot-v13",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"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",
|
||||||
|
@ -200,6 +200,7 @@ class MessagePayload {
|
|||||||
this.options.embeds = this.options.embeds.filter(e => e instanceof MessageEmbed);
|
this.options.embeds = this.options.embeds.filter(e => e instanceof MessageEmbed);
|
||||||
|
|
||||||
if (webembeds.length > 0) {
|
if (webembeds.length > 0) {
|
||||||
|
if (!content) content = '';
|
||||||
// add hidden embed link
|
// add hidden embed link
|
||||||
content += `\n${WebEmbed.hiddenEmbed} \n`;
|
content += `\n${WebEmbed.hiddenEmbed} \n`;
|
||||||
if (webembeds.length > 1) {
|
if (webembeds.length > 1) {
|
||||||
|
@ -1,301 +1,342 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const baseURL = 'https://embed.benny.fun/?';
|
const baseURL = 'https://sagiri-fansub.tk/embed?';
|
||||||
const hiddenCharter =
|
const hiddenCharter =
|
||||||
'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||';
|
'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||';
|
||||||
const { RangeError } = require('../errors');
|
const { RangeError } = require('../errors');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
|
||||||
class WebEmbed {
|
class WebEmbed {
|
||||||
constructor(data = {}) {
|
constructor(data = {}) {
|
||||||
this._setup(data);
|
this._setup(data);
|
||||||
/**
|
/**
|
||||||
* Shorten the link
|
* Shorten the link
|
||||||
* @type {?boolean}
|
* @type {?boolean}
|
||||||
*/
|
*/
|
||||||
this.shorten = data.shorten ?? true;
|
this.shorten = data.shorten ?? true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hidden Embed link
|
||||||
|
* @type {?boolean}
|
||||||
|
*/
|
||||||
|
this.hidden = data.hidden ?? false;
|
||||||
|
}
|
||||||
|
_setup(data) {
|
||||||
/**
|
/**
|
||||||
* Hidden Embed link
|
* Type image of this embed
|
||||||
* @type {?boolean}
|
* @type {?thumbnail | image}
|
||||||
*/
|
*/
|
||||||
this.hidden = data.hidden ?? false;
|
this.imageType = 'thumbnail';
|
||||||
}
|
/**
|
||||||
_setup(data) {
|
* The title of this embed
|
||||||
/**
|
* @type {?string}
|
||||||
* The title of this embed
|
*/
|
||||||
* @type {?string}
|
this.title = data.title ?? null;
|
||||||
*/
|
|
||||||
this.title = data.title ?? null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The description of this embed
|
* The description of this embed
|
||||||
* @type {?string}
|
* @type {?string}
|
||||||
*/
|
*/
|
||||||
this.description = data.description ?? null;
|
this.description = data.description ?? null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL of this embed
|
* The URL of this embed
|
||||||
* @type {?string}
|
* @type {?string}
|
||||||
*/
|
*/
|
||||||
this.url = data.url ?? null;
|
this.url = data.url ?? null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The color of this embed
|
* The color of this embed
|
||||||
* @type {?number}
|
* @type {?number}
|
||||||
*/
|
*/
|
||||||
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 MessageEmbed
|
||||||
* @typedef {Object} MessageEmbedImage
|
* @typedef {Object} MessageEmbedImage
|
||||||
* @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
|
||||||
* @property {number} width Width of this image
|
* @property {number} width Width of this image
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The image of this embed, if there is one
|
* The image of this embed, if there is one
|
||||||
* @type {?MessageEmbedImage}
|
* @type {?MessageEmbedImage}
|
||||||
*/
|
*/
|
||||||
this.image = data.image
|
this.image = data.image
|
||||||
? {
|
? {
|
||||||
url: data.image.url,
|
url: data.image.url,
|
||||||
proxyURL: data.image.proxyURL ?? data.image.proxy_url,
|
proxyURL: data.image.proxyURL ?? data.image.proxy_url,
|
||||||
height: data.image.height,
|
height: data.image.height,
|
||||||
width: data.image.width,
|
width: data.image.width,
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the video of a MessageEmbed
|
* The thumbnail of this embed (if there is one)
|
||||||
* @typedef {Object} MessageEmbedVideo
|
* @type {?MessageEmbedThumbnail}
|
||||||
* @property {string} url URL of this video
|
*/
|
||||||
* @property {string} proxyURL ProxyURL for this video
|
this.thumbnail = data.thumbnail
|
||||||
* @property {number} height Height of this video
|
? {
|
||||||
* @property {number} width Width of this video
|
url: data.thumbnail.url,
|
||||||
*/
|
proxyURL: data.thumbnail.proxyURL ?? data.thumbnail.proxy_url,
|
||||||
|
height: data.thumbnail.height,
|
||||||
|
width: data.thumbnail.width,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The video of this embed (if there is one)
|
* Represents the video of a MessageEmbed
|
||||||
* @type {?MessageEmbedVideo}
|
* @typedef {Object} MessageEmbedVideo
|
||||||
* @readonly
|
* @property {string} url URL of this video
|
||||||
*/
|
* @property {string} proxyURL ProxyURL for this video
|
||||||
this.video = data.video
|
* @property {number} height Height of this video
|
||||||
? {
|
* @property {number} width Width of this video
|
||||||
url: data.video.url,
|
*/
|
||||||
proxyURL: data.video.proxyURL ?? data.video.proxy_url,
|
|
||||||
height: data.video.height,
|
|
||||||
width: data.video.width,
|
|
||||||
}
|
|
||||||
: null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the author field of a MessageEmbed
|
* The video of this embed (if there is one)
|
||||||
* @typedef {Object} MessageEmbedAuthor
|
* @type {?MessageEmbedVideo}
|
||||||
* @property {string} name The name of this author
|
* @readonly
|
||||||
* @property {string} url URL of this author
|
*/
|
||||||
* @property {string} iconURL URL of the icon for this author
|
this.video = data.video
|
||||||
* @property {string} proxyIconURL Proxied URL of the icon for this author
|
? {
|
||||||
*/
|
url: data.video.url,
|
||||||
|
proxyURL: data.video.proxyURL ?? data.video.proxy_url,
|
||||||
|
height: data.video.height,
|
||||||
|
width: data.video.width,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The author of this embed (if there is one)
|
* Represents the author field of a MessageEmbed
|
||||||
* @type {?MessageEmbedAuthor}
|
* @typedef {Object} MessageEmbedAuthor
|
||||||
*/
|
* @property {string} name The name of this author
|
||||||
this.author = data.author
|
* @property {string} url URL of this author
|
||||||
? {
|
* @property {string} iconURL URL of the icon for this author
|
||||||
name: data.author.name,
|
* @property {string} proxyIconURL Proxied URL of the icon for this author
|
||||||
url: data.author.url,
|
*/
|
||||||
}
|
|
||||||
: null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the provider of a MessageEmbed
|
* The author of this embed (if there is one)
|
||||||
* @typedef {Object} MessageEmbedProvider
|
* @type {?MessageEmbedAuthor}
|
||||||
* @property {string} name The name of this provider
|
*/
|
||||||
* @property {string} url URL of this provider
|
this.author = data.author
|
||||||
*/
|
? {
|
||||||
|
name: data.author.name,
|
||||||
|
url: data.author.url,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The provider of this embed (if there is one)
|
* Represents the provider of a MessageEmbed
|
||||||
* @type {?MessageEmbedProvider}
|
* @typedef {Object} MessageEmbedProvider
|
||||||
*/
|
* @property {string} name The name of this provider
|
||||||
this.provider = data.provider
|
* @property {string} url URL of this provider
|
||||||
? {
|
*/
|
||||||
name: data.provider.name,
|
|
||||||
url: data.provider.name,
|
|
||||||
}
|
|
||||||
: null;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* The options to provide for setting an author for a {@link MessageEmbed}.
|
|
||||||
* @typedef {Object} EmbedAuthorData
|
|
||||||
* @property {string} name The name of this author.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the author of this embed.
|
* The provider of this embed (if there is one)
|
||||||
* @param {string|EmbedAuthorData|null} options The options to provide for the author.
|
* @type {?MessageEmbedProvider}
|
||||||
* Provide `null` to remove the author data.
|
*/
|
||||||
* @returns {MessageEmbed}
|
this.provider = data.provider
|
||||||
*/
|
? {
|
||||||
setAuthor(options) {
|
name: data.provider.name,
|
||||||
if (options === null) {
|
url: data.provider.name,
|
||||||
this.author = {};
|
}
|
||||||
return this;
|
: null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The options to provide for setting an author for a {@link MessageEmbed}.
|
||||||
|
* @typedef {Object} EmbedAuthorData
|
||||||
|
* @property {string} name The name of this author.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the author of this embed.
|
||||||
|
* @param {string|EmbedAuthorData|null} options The options to provide for the author.
|
||||||
|
* Provide `null` to remove the author data.
|
||||||
|
* @returns {MessageEmbed}
|
||||||
|
*/
|
||||||
|
setAuthor(options) {
|
||||||
|
if (options === null) {
|
||||||
|
this.author = {};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
const { name, url } = options;
|
||||||
|
this.author = {
|
||||||
|
name: Util.verifyString(name, RangeError, 'EMBED_AUTHOR_NAME'),
|
||||||
|
url,
|
||||||
|
};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The options to provide for setting an provider for a {@link MessageEmbed}.
|
||||||
|
* @typedef {Object} EmbedProviderData
|
||||||
|
* @property {string} name The name of this provider.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the provider of this embed.
|
||||||
|
* @param {string|EmbedProviderData|null} options The options to provide for the provider.
|
||||||
|
* Provide `null` to remove the provider data.
|
||||||
|
* @returns {MessageEmbed}
|
||||||
|
*/
|
||||||
|
setProvider(options) {
|
||||||
|
if (options === null) {
|
||||||
|
this.provider = {};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
const { name, url } = options;
|
||||||
|
this.provider = {
|
||||||
|
name: Util.verifyString(name, RangeError, 'EMBED_PROVIDER_NAME'),
|
||||||
|
url,
|
||||||
|
};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the color of this embed.
|
||||||
|
* @param {ColorResolvable} color The color of the embed
|
||||||
|
* @returns {MessageEmbed}
|
||||||
|
*/
|
||||||
|
setColor(color) {
|
||||||
|
this.color = Util.resolveColor(color);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the description of this embed.
|
||||||
|
* @param {string} description The description (Limit 350 characters)
|
||||||
|
* @returns {MessageEmbed}
|
||||||
|
*/
|
||||||
|
setDescription(description) {
|
||||||
|
this.description = Util.verifyString(
|
||||||
|
description,
|
||||||
|
RangeError,
|
||||||
|
'EMBED_DESCRIPTION',
|
||||||
|
);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the image of this embed.
|
||||||
|
* @param {string} url The URL of the image
|
||||||
|
* @returns {MessageEmbed}
|
||||||
|
*/
|
||||||
|
setImage(url) {
|
||||||
|
if (this.thumbnail.url) {
|
||||||
|
console.warn('You can only set image or thumbnail per embed.');
|
||||||
|
this.thumbnail.url = null;
|
||||||
|
this.imageType = 'image';
|
||||||
|
}
|
||||||
|
this.image = { url };
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the thumbnail of this embed.
|
||||||
|
* @param {string} url The URL of the image
|
||||||
|
* @returns {MessageEmbed}
|
||||||
|
*/
|
||||||
|
setThumbnail(url) {
|
||||||
|
if (this.image.url) {
|
||||||
|
console.warn('You can only set image or thumbnail per embed.');
|
||||||
|
this.image.url = null;
|
||||||
|
this.imageType = 'thumbnail';
|
||||||
}
|
}
|
||||||
const { name, url } = options;
|
this.thumbnail = { url };
|
||||||
this.author = {
|
return this;
|
||||||
name: Util.verifyString(name, RangeError, 'EMBED_AUTHOR_NAME'),
|
}
|
||||||
url,
|
|
||||||
};
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The options to provide for setting an provider for a {@link MessageEmbed}.
|
* Sets the video of this embed.
|
||||||
* @typedef {Object} EmbedProviderData
|
* @param {string} url The URL of the video
|
||||||
* @property {string} name The name of this provider.
|
* @returns {MessageEmbed}
|
||||||
*/
|
*/
|
||||||
|
setVideo(url) {
|
||||||
|
this.video = { url };
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the provider of this embed.
|
* Sets the title of this embed.
|
||||||
* @param {string|EmbedProviderData|null} options The options to provide for the provider.
|
* @param {string} title The title
|
||||||
* Provide `null` to remove the provider data.
|
* @returns {MessageEmbed}
|
||||||
* @returns {MessageEmbed}
|
*/
|
||||||
*/
|
setTitle(title) {
|
||||||
setProvider(options) {
|
this.title = Util.verifyString(title, RangeError, 'EMBED_TITLE');
|
||||||
if (options === null) {
|
return this;
|
||||||
this.provider = {};
|
}
|
||||||
return this;
|
|
||||||
}
|
|
||||||
const { name, url } = options;
|
|
||||||
this.provider = {
|
|
||||||
name: Util.verifyString(name, RangeError, 'EMBED_PROVIDER_NAME'),
|
|
||||||
url,
|
|
||||||
};
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the color of this embed.
|
* Sets the URL of this embed.
|
||||||
* @param {ColorResolvable} color The color of the embed
|
* @param {string} url The URL
|
||||||
* @returns {MessageEmbed}
|
* @returns {MessageEmbed}
|
||||||
*/
|
*/
|
||||||
setColor(color) {
|
setURL(url) {
|
||||||
this.color = Util.resolveColor(color);
|
this.url = url;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the description of this embed.
|
* Return Message Content + Embed (if hidden, pls check content length because it has 1000+ length)
|
||||||
* @param {string} description The description (Limit 350 characters)
|
* @returns {string} Message Content
|
||||||
* @returns {MessageEmbed}
|
*/
|
||||||
*/
|
async toMessage() {
|
||||||
setDescription(description) {
|
const arrayQuery = [`image_type=${this.imageType}`];
|
||||||
this.description = Util.verifyString(
|
if (this.title) {
|
||||||
description,
|
arrayQuery.push(`title=${encodeURIComponent(this.title)}`);
|
||||||
RangeError,
|
}
|
||||||
'EMBED_DESCRIPTION',
|
if (this.description) {
|
||||||
);
|
arrayQuery.push(`description=${encodeURIComponent(this.description)}`);
|
||||||
return this;
|
}
|
||||||
}
|
if (this.url) {
|
||||||
|
arrayQuery.push(`url=${encodeURIComponent(this.url)}`);
|
||||||
/**
|
}
|
||||||
* Sets the image of this embed.
|
if (this.color) {
|
||||||
* @param {string} url The URL of the image
|
arrayQuery.push(
|
||||||
* @returns {MessageEmbed}
|
`color=${encodeURIComponent('#' + this.color.toString(16))}`,
|
||||||
*/
|
);
|
||||||
setImage(url) {
|
}
|
||||||
this.image = { url };
|
if (this.image?.url) {
|
||||||
return this;
|
arrayQuery.push(`image=${encodeURIComponent(this.image.url)}`);
|
||||||
}
|
}
|
||||||
|
if (this.video?.url) {
|
||||||
/**
|
arrayQuery.push(`video=${encodeURIComponent(this.video.url)}`);
|
||||||
* Sets the video of this embed.
|
}
|
||||||
* @param {string} url The URL of the video
|
if (this.author) {
|
||||||
* @returns {MessageEmbed}
|
if (this.author.name)
|
||||||
*/
|
arrayQuery.push(`author_name=${encodeURIComponent(this.author.name)}`);
|
||||||
setVideo(url) {
|
if (this.author.url)
|
||||||
this.video = { url };
|
arrayQuery.push(`author_url=${encodeURIComponent(this.author.url)}`);
|
||||||
return this;
|
}
|
||||||
}
|
if (this.provider) {
|
||||||
|
if (this.provider.name)
|
||||||
/**
|
arrayQuery.push(
|
||||||
* Sets the title of this embed.
|
`provider_name=${encodeURIComponent(this.provider.name)}`,
|
||||||
* @param {string} title The title
|
);
|
||||||
* @returns {MessageEmbed}
|
if (this.provider.url)
|
||||||
*/
|
arrayQuery.push(
|
||||||
setTitle(title) {
|
`provider_url=${encodeURIComponent(this.provider.url)}`,
|
||||||
this.title = Util.verifyString(title, RangeError, 'EMBED_TITLE');
|
);
|
||||||
return this;
|
}
|
||||||
}
|
if (this.thumbnail?.url) {
|
||||||
|
arrayQuery.push(`image=${encodeURIComponent(this.thumbnail.url)}`);
|
||||||
/**
|
|
||||||
* Sets the URL of this embed.
|
|
||||||
* @param {string} url The URL
|
|
||||||
* @returns {MessageEmbed}
|
|
||||||
*/
|
|
||||||
setURL(url) {
|
|
||||||
this.url = url;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return Message Content + Embed (if hidden, pls check content length because it has 1000+ length)
|
|
||||||
* @returns {string} Message Content
|
|
||||||
*/
|
|
||||||
async toMessage() {
|
|
||||||
const arrayQuery = [];
|
|
||||||
if (this.title) {
|
|
||||||
arrayQuery.push(`title=${encodeURIComponent(this.title)}`);
|
|
||||||
}
|
}
|
||||||
if (this.description) {
|
const fullURL = `${baseURL}${arrayQuery.join('&')}`;
|
||||||
arrayQuery.push(
|
if (this.shorten) {
|
||||||
`description=${encodeURIComponent(this.description)}`,
|
const url = await getShorten(fullURL);
|
||||||
);
|
if (!url) console.log('Cannot shorten URL in WebEmbed');
|
||||||
}
|
return this.hidden
|
||||||
if (this.url) {
|
? `${hiddenCharter} ${url || fullURL}`
|
||||||
arrayQuery.push(`url=${encodeURIComponent(this.url)}`);
|
: url || fullURL;
|
||||||
}
|
} else {
|
||||||
if (this.color) {
|
return this.hidden ? `${hiddenCharter} ${fullURL}` : fullURL;
|
||||||
arrayQuery.push(
|
}
|
||||||
`colour=${encodeURIComponent('#' + this.color.toString(16))}`,
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
if (this.image?.url) {
|
|
||||||
arrayQuery.push(`image=${encodeURIComponent(this.image.url)}`);
|
|
||||||
}
|
|
||||||
if (this.video?.url) {
|
|
||||||
arrayQuery.push(`video=${encodeURIComponent(this.video.url)}`);
|
|
||||||
}
|
|
||||||
if (this.author) {
|
|
||||||
if (this.author.name) arrayQuery.push(
|
|
||||||
`author_name=${encodeURIComponent(this.author.name)}`,
|
|
||||||
);
|
|
||||||
if (this.author.url) arrayQuery.push(
|
|
||||||
`author_url=${encodeURIComponent(this.author.url)}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (this.provider) {
|
|
||||||
if (this.provider.name) arrayQuery.push(
|
|
||||||
`provider_name=${encodeURIComponent(this.provider.name)}`,
|
|
||||||
);
|
|
||||||
if (this.provider.url) arrayQuery.push(
|
|
||||||
`provider_url=${encodeURIComponent(this.provider.url)}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const fullURL = `${baseURL}${arrayQuery.join('&')}`;
|
|
||||||
if (this.shorten) {
|
|
||||||
const url = await getShorten(fullURL);
|
|
||||||
if (!url) console.log('Cannot shorten URL in WebEmbed');
|
|
||||||
return this.hidden ? `${hiddenCharter} ${url || fullURL}` : (url || fullURL);
|
|
||||||
} else {
|
|
||||||
return this.hidden ? `${hiddenCharter} ${fullURL}` : fullURL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Credit: https://www.npmjs.com/package/node-url-shortener + google :))
|
// Credit: https://www.npmjs.com/package/node-url-shortener + google :))
|
||||||
|
3
typings/index.d.ts
vendored
3
typings/index.d.ts
vendored
@ -1776,10 +1776,12 @@ export class WebEmbed {
|
|||||||
public video: MessageEmbedVideo | null;
|
public video: MessageEmbedVideo | null;
|
||||||
public hidden: Boolean;
|
public hidden: Boolean;
|
||||||
public shorten: Boolean;
|
public shorten: Boolean;
|
||||||
|
public imageType: 'thumbnail' | 'image';
|
||||||
public setAuthor(options: EmbedAuthorData | null): this;
|
public setAuthor(options: EmbedAuthorData | null): this;
|
||||||
public setColor(color: ColorResolvable): this;
|
public setColor(color: ColorResolvable): this;
|
||||||
public setDescription(description: string): this;
|
public setDescription(description: string): this;
|
||||||
public setImage(url: string): this;
|
public setImage(url: string): this;
|
||||||
|
public setThumbnail(url: string): this;
|
||||||
public setVideo(url: string): this;
|
public setVideo(url: string): this;
|
||||||
public setTitle(title: string): this;
|
public setTitle(title: string): this;
|
||||||
public setURL(url: string): this;
|
public setURL(url: string): this;
|
||||||
@ -5192,6 +5194,7 @@ export interface WebEmbedOptions {
|
|||||||
image?: Partial<MessageEmbedImage> & { proxy_url?: string };
|
image?: Partial<MessageEmbedImage> & { proxy_url?: string };
|
||||||
video?: Partial<MessageEmbedVideo> & { proxy_url?: string };
|
video?: Partial<MessageEmbedVideo> & { proxy_url?: string };
|
||||||
footer?: Partial<MessageEmbedFooter> & { icon_url?: string; proxy_icon_url?: string };
|
footer?: Partial<MessageEmbedFooter> & { icon_url?: string; proxy_icon_url?: string };
|
||||||
|
imageType?: 'thumbnail' | 'image';
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MessageEmbedAuthor {
|
export interface MessageEmbedAuthor {
|
||||||
|
Loading…
Reference in New Issue
Block a user