feat(WebEmbed) Custom API, Custom ShortenAPI, and open-source API
https://github.com/aiko-chan-ai/WebEmbed
This commit is contained in:
parent
3b2d88caf9
commit
58b4179e81
10
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
10
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -2,6 +2,16 @@ name: Bug report
|
||||
description: Report incorrect or unexpected behavior of a package
|
||||
labels: [bug, need repro]
|
||||
body:
|
||||
- type: dropdown
|
||||
id: package
|
||||
attributes:
|
||||
label: Which package has the bugs?
|
||||
options:
|
||||
- The core library
|
||||
- The documentation
|
||||
- WebEmbed x Shorten API
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
|
1
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
1
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@ -14,6 +14,7 @@ body:
|
||||
options:
|
||||
- The core library
|
||||
- The documentation
|
||||
- WebEmbed x Shorten API
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
@ -69,9 +69,12 @@ In this way, all Slash commands can be obtained
|
||||
Code:
|
||||
```js
|
||||
const Discord = require('discord.js-selfbot-v13');
|
||||
// Selfhost WebEmbed: https://github.com/aiko-chan-ai/WebEmbed
|
||||
const w = new Discord.WebEmbed({
|
||||
shorten: true,
|
||||
hidden: false // if you send this embed with MessagePayload.options.embeds, it must set to false
|
||||
baseURL: '', // if you want self-host API, else skip :v
|
||||
shortenAPI: '', // if you want Custom shortenAPI (Method: Get, response: Text => URL), else skip :v
|
||||
})
|
||||
.setAuthor({ name: 'hello', url: 'https://google.com' })
|
||||
.setColor('RED')
|
||||
|
2
LICENSE
2
LICENSE
@ -1,7 +1,7 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Copyright (C) 2022 aiko-chan-ai and discordjs
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
16
README.md
16
README.md
@ -32,8 +32,8 @@
|
||||
|
||||
|
||||
### <strong>[Document Website (recommend)](https://discordjs-self-v13.netlify.app/)</strong>
|
||||
But if you want to see some specific notes (with pictures) you can go to [here](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/tree/main/Document)
|
||||
### <strong>[Risky actions](https://github.com/Merubokkusu/Discord-S.C.U.M/issues/66)</strong>
|
||||
|
||||
### <strong>[Extend Document (With Example)](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/tree/main/Document)</strong>
|
||||
|
||||
## Checklist
|
||||
- [x] Send + receive messages (not send Embed :v ).
|
||||
@ -95,17 +95,6 @@ console.log(`%cYou now have your token in the clipboard!`, 'font-size: 16px');
|
||||
|
||||
Credit: <img src="https://cdn.discordapp.com/emojis/889092230063734795.png" alt="." width="16" height="16"/> [<strong>hxr404</strong>](https://github.com/hxr404/Discord-Console-hacks)
|
||||
|
||||
## Links (Discord.js)
|
||||
|
||||
- [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website))
|
||||
- [Documentation](https://discord.js.org/#/docs)
|
||||
- [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide))
|
||||
See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v13.html), including updated and removed items in the library.
|
||||
- [discord.js Discord server](https://discord.gg/djs)
|
||||
- [Discord API Discord server](https://discord.gg/discord-api)
|
||||
- [GitHub](https://github.com/discordjs/discord.js)
|
||||
- [npm](https://www.npmjs.com/package/discord.js)
|
||||
- [Related libraries](https://discord.com/developers/docs/topics/community-resources#libraries)
|
||||
|
||||
## Contributing
|
||||
|
||||
@ -120,7 +109,6 @@ Contact me in Discord: [Shiraori#1782](https://discord.com/users/721746046543331
|
||||
- [Discord.js](https://github.com/discordjs/discord.js)
|
||||
- [Discord S.C.U.M](https://github.com/Merubokkusu/Discord-S.C.U.M)
|
||||
- [Discord Console Hack](https://github.com/hxr404/Discord-Console-hacks)
|
||||
- And the people who submitted the issue, colab, ...
|
||||
|
||||
## <strong><img src="https://cdn.discordapp.com/attachments/820557032016969751/952436539118456882/flag-vietnam_1f1fb-1f1f3.png" alt="." width="20" height="20"/> Vietnamese</strong>
|
||||
Được tạo bởi người Việt Nam, dựa trên Discord API v9, đây là một trong những module selfbot được hỗ trợ tốt nhất.
|
||||
|
File diff suppressed because one or more lines are too long
@ -208,7 +208,7 @@ class MessagePayload {
|
||||
// Add hidden embed link
|
||||
content += `\n${WebEmbed.hiddenEmbed} \n`;
|
||||
if (webembeds.length > 1) {
|
||||
console.warn('Multiple webembeds are not supported, this will be ignored.');
|
||||
console.warn('[WARN] Multiple webembeds are not supported, this will be ignored.');
|
||||
}
|
||||
// Const embed = webembeds[0];
|
||||
for (const webE of webembeds) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
const axios = require('axios');
|
||||
const baseURL = 'https://sagiri-fansub.tk/embed?';
|
||||
const baseURL = 'https://sagiri-v3dot3.herokuapp.com/embed?';
|
||||
const hiddenCharter =
|
||||
'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||';
|
||||
const { RangeError } = require('../errors');
|
||||
@ -49,6 +49,20 @@ class WebEmbed {
|
||||
* @type {?boolean}
|
||||
*/
|
||||
this.hidden = data.hidden ?? false;
|
||||
|
||||
/**
|
||||
* Using Custom WebEmbed server ?
|
||||
* @type {?string} https://sagiri-v3dot3.herokuapp.com/embed?
|
||||
* @see https://github.com/aiko-chan-ai/WebEmbed
|
||||
*/
|
||||
this.baseURL = data.baseURL ?? baseURL;
|
||||
|
||||
/**
|
||||
* Shorten API
|
||||
* @type {?string} https://sagiri-v3dot3.herokuapp.com/short?url=
|
||||
* @see https://github.com/aiko-chan-ai/WebEmbed
|
||||
*/
|
||||
this.shortenAPI = data.shortenAPI;
|
||||
}
|
||||
/**
|
||||
* @private
|
||||
@ -353,9 +367,9 @@ class WebEmbed {
|
||||
if (this.thumbnail?.url) {
|
||||
arrayQuery.push(`image=${encodeURIComponent(this.thumbnail.url)}`);
|
||||
}
|
||||
const fullURL = `${baseURL}${arrayQuery.join('&')}`;
|
||||
const fullURL = `${this.baseURL}${arrayQuery.join('&')}`;
|
||||
if (this.shorten) {
|
||||
const url = await getShorten(fullURL);
|
||||
const url = await getShorten(fullURL, this);
|
||||
if (!url) console.log('Cannot shorten URL in WebEmbed');
|
||||
return this.hidden ? `${hiddenCharter} ${url || fullURL}` : url || fullURL;
|
||||
} else {
|
||||
@ -365,14 +379,20 @@ class WebEmbed {
|
||||
}
|
||||
|
||||
// Credit: https://www.npmjs.com/package/node-url-shortener + google :))
|
||||
const getShorten = async url => {
|
||||
const getShorten = async (url, embed) => {
|
||||
const APIurl = [
|
||||
'https://tinyurl.com/api-create.php?url=',
|
||||
'https://sagiri-fansub.tk/api/v1/short?url=', // My api, pls don't ddos :(
|
||||
// 'https://sagiri-fansub.tk/api/v1/short?url=', // My api, pls don't ddos :(
|
||||
'https://sagiri-v3dot3.herokuapp.com/short?url=', // My api, pls don't ddos :(
|
||||
// 'https://lazuee.ga/api/v1/shorten?url=',
|
||||
];
|
||||
const shorten = `${
|
||||
embed.shortenAPI && typeof embed.shortenAPI == 'string'
|
||||
? embed.shortenAPI
|
||||
: APIurl[Math.floor(Math.random() * APIurl.length)]
|
||||
}${encodeURIComponent(url)}`;
|
||||
try {
|
||||
const res = await axios.get(`${APIurl[Math.floor(Math.random() * APIurl.length)]}${encodeURIComponent(url)}`);
|
||||
const res = await axios.get(`${shorten}`);
|
||||
if (typeof res.data === 'string') return res.data;
|
||||
else if (typeof res.data === 'object') return res.data.shorten;
|
||||
else throw new Error('Unknown error');
|
||||
|
Loading…
Reference in New Issue
Block a user