From fe8d9786f02c2549c5f0da5e913d658a322098c7 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sun, 3 Apr 2022 12:35:38 +0700 Subject: [PATCH] encodeURL --- src/structures/WebEmbed.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/structures/WebEmbed.js b/src/structures/WebEmbed.js index 55b0902..2dcd039 100644 --- a/src/structures/WebEmbed.js +++ b/src/structures/WebEmbed.js @@ -9,8 +9,6 @@ const Util = require('../util/Util'); class WebEmbed { constructor(data = {}) { this._setup(data); - } - _setup(data) { /** * Shorten the link * @type {?boolean} @@ -22,6 +20,8 @@ class WebEmbed { * @type {?boolean} */ this.hidden = data.hidden ?? false; + } + _setup(data) { /** * The title of this embed * @type {?string} @@ -301,15 +301,17 @@ class WebEmbed { // Credit: https://www.npmjs.com/package/node-url-shortener + google :)) const getShorten = async (url) => { const APIurl = [ - // 'https://is.gd/create.php?format=simple&url=', :( - 'https://tinyurl.com/api-create.php?url=', - 'https://sagiri-fansub.tk/api/v1/short?url=', // my api, pls don't ddos :( - // 'https://cdpt.in/shorten?url=', Redirects 5s :( - ]; + // 'https://is.gd/create.php?format=simple&url=', :( + 'https://tinyurl.com/api-create.php?url=', + 'https://sagiri-fansub.tk/api/v1/short?url=', // my api, pls don't ddos :( + // 'https://cdpt.in/shorten?url=', Redirects 5s :( + ]; try { 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}`; } catch { return void 0;