From 5a30a642305bb4c2064976ad7bf97c10662b7a0b Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Wed, 4 Dec 2024 12:55:18 +0500 Subject: [PATCH] fix shorturl --- commands/General/shorturl.js | 6 ++++-- languages/en-US/general/shorturl.json | 3 ++- languages/ru-RU/general/shorturl.json | 2 +- languages/uk-UA/general/shorturl.json | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/commands/General/shorturl.js b/commands/General/shorturl.js index fb889b88..06da073d 100644 --- a/commands/General/shorturl.js +++ b/commands/General/shorturl.js @@ -51,7 +51,9 @@ class Shorturl extends BaseCommand { await interaction.deferReply({ ephemeral: interaction.options.getBoolean("ephemeral") || false }); const url = interaction.options.getString("url"); - const res = fetch("https://s.jonnybro.ru/api/link/create", { + if (!url.startsWith("http")) return interaction.error("general/shorturl:NOT_A_LINK", null, { edit: true }); + + const res = await fetch("https://s.jonnybro.ru/api/link/create", { method: "POST", headers: { "Authorization": `Bearer ${client.config.apiKeys.sink}`, @@ -61,7 +63,7 @@ class Shorturl extends BaseCommand { }).then(res => res.json()); interaction.editReply({ - content: ``, + content: ``, }); } } diff --git a/languages/en-US/general/shorturl.json b/languages/en-US/general/shorturl.json index 542b62d6..121f4655 100644 --- a/languages/en-US/general/shorturl.json +++ b/languages/en-US/general/shorturl.json @@ -1,5 +1,6 @@ { "DESCRIPTION": "Shortens a URL", "USAGE": "[url]", - "EXAMPLES": "shorturl url:https://google.com" + "EXAMPLES": "shorturl url:https://google.com", + "NOT_A_LINK": "Provide a proper URL!" } \ No newline at end of file diff --git a/languages/ru-RU/general/shorturl.json b/languages/ru-RU/general/shorturl.json index 76e304f3..00bda6f0 100644 --- a/languages/ru-RU/general/shorturl.json +++ b/languages/ru-RU/general/shorturl.json @@ -2,5 +2,5 @@ "DESCRIPTION": "Укоротить ссылку", "USAGE": "[url]", "EXAMPLES": "shorturl url:https://google.com", - "URL": "Ссылка" + "NOT_A_LINK": "Укажите правильный URL!" } \ No newline at end of file diff --git a/languages/uk-UA/general/shorturl.json b/languages/uk-UA/general/shorturl.json index 90774a15..20d97df2 100644 --- a/languages/uk-UA/general/shorturl.json +++ b/languages/uk-UA/general/shorturl.json @@ -2,5 +2,5 @@ "DESCRIPTION": "Укоротити посилання", "USAGE": "[url]", "EXAMPLES": "shorturl url:https://google.com", - "URL": "Посилання" + "NOT_A_LINK": "Вкажіть правильну URL!" } \ No newline at end of file