From 8bbc22c06c5a8f2df9fb30e95d90eb6f14d983d5 Mon Sep 17 00:00:00 2001 From: night0721 Date: Sat, 8 Jan 2022 08:06:52 +0800 Subject: [PATCH] Version v3.5.0 --- unused/commands/Utilities/shorturl.js | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 unused/commands/Utilities/shorturl.js diff --git a/unused/commands/Utilities/shorturl.js b/unused/commands/Utilities/shorturl.js new file mode 100644 index 0000000..768edc4 --- /dev/null +++ b/unused/commands/Utilities/shorturl.js @@ -0,0 +1,35 @@ +const URLClient = require("../../../client/URLClient"); +module.exports = { + name: "shorten-url", + description: "Shorten a URL", + options: [ + { + type: 3, + name: "short-name", + description: + "The short name that for the shorten-url (For example, https://url.cath.gq/youtube)", + required: true, + }, + { + type: 3, + name: "link", + description: + "The link for the shorten-url (For example, https://youtube.com)", + required: true, + }, + ], + run: async (client, interaction, args) => { + if (!args[1].includes("https://")) { + interaction.followUp({ content: "The link must contain 'https://'" }); + } else { + const shortName = args[0]; + const targetURL = args[1]; + const cc = await URLClient.createShortURL(shortName, targetURL); + if (!cc) { + interaction.followUp({ content: `URL already exist` }); + } else { + interaction.followUp({ content: `https://url.cath.gq/${cc}` }); + } + } + }, +};