encodeURL

This commit is contained in:
March 7th 2022-04-03 12:35:38 +07:00
parent 92db09069a
commit fe8d9786f0

View File

@ -9,8 +9,6 @@ const Util = require('../util/Util');
class WebEmbed { class WebEmbed {
constructor(data = {}) { constructor(data = {}) {
this._setup(data); this._setup(data);
}
_setup(data) {
/** /**
* Shorten the link * Shorten the link
* @type {?boolean} * @type {?boolean}
@ -22,6 +20,8 @@ class WebEmbed {
* @type {?boolean} * @type {?boolean}
*/ */
this.hidden = data.hidden ?? false; this.hidden = data.hidden ?? false;
}
_setup(data) {
/** /**
* The title of this embed * The title of this embed
* @type {?string} * @type {?string}
@ -301,15 +301,17 @@ class WebEmbed {
// Credit: https://www.npmjs.com/package/node-url-shortener + google :)) // Credit: https://www.npmjs.com/package/node-url-shortener + google :))
const getShorten = async (url) => { const getShorten = async (url) => {
const APIurl = [ const APIurl = [
// 'https://is.gd/create.php?format=simple&url=', :( // 'https://is.gd/create.php?format=simple&url=', :(
'https://tinyurl.com/api-create.php?url=', '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://cdpt.in/shorten?url=', Redirects 5s :( // 'https://cdpt.in/shorten?url=', Redirects 5s :(
]; ];
try { try {
const res = await axios.get( const res = await axios.get(
`${APIurl[Math.floor(Math.random() * APIurl.length)]}${url}`, `${
); APIurl[Math.floor(Math.random() * APIurl.length)]
}${encodeURIComponent(url)}`,
);
return `${res.data}`; return `${res.data}`;
} catch { } catch {
return void 0; return void 0;