From 0b21f0ffb8daa24af74a64b6b98a26c8181b7e7c Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Sun, 18 Dec 2022 15:07:50 +0700 Subject: [PATCH] improve url loading in draw and music playurl --- commands/draw.js | 8 +++++--- commands/music.js | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/commands/draw.js b/commands/draw.js index 6252460..7ba5ca0 100644 --- a/commands/draw.js +++ b/commands/draw.js @@ -9,10 +9,11 @@ module.exports = { trusted: 0, usage: '', execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { + let image try { const url = args.join(' ') - const image = await axios.get('https://http-proxy.nongsonchome.repl.co', { + image = await axios.get('https://http-proxy.nongsonchome.repl.co', { params: { uri: url }, @@ -32,8 +33,9 @@ module.exports = { .toBuffer({ resolveWithObject: true }) bot.draw(data, info) - } catch (e) { - bot.tellraw(selector, { text: 'SyntaxError: Invalid URL', color: 'red' }) + } catch (_err) { + const e = image.data.toString() + bot.tellraw(selector, { text: e, color: 'red' }) } } } diff --git a/commands/music.js b/commands/music.js index 51c02be..70f4b8e 100644 --- a/commands/music.js +++ b/commands/music.js @@ -48,9 +48,10 @@ async function play (bot, values, discord, channeldc, selector, config) { } async function playUrl (bot, values, discord, channeldc, selector, config) { + let response try { const url = values.join(' ') - const response = await axios.get('https://http-proxy.nongsonchome.repl.co', { + response = await axios.get('https://http-proxy.nongsonchome.repl.co', { params: { uri: url }, @@ -68,15 +69,16 @@ async function playUrl (bot, values, discord, channeldc, selector, config) { } else { bot.tellraw(selector, [{ text: 'Added ', color: 'white' }, { text: song.name, color: 'gold' }, { text: ' to the song queue', color: 'white' }]) } - } catch (e) { + } catch (_err) { + const e = response.data.toString() if (discord) { const Embed = new MessageEmbed() .setColor(config.discord.embedsColors.error) .setTitle('Error') - .setDescription('```SyntaxError: Invalid URL```') + .setDescription(`\`\`\`${e}\`\`\``) channeldc.send({ embeds: [Embed] }) } else { - bot.tellraw(selector, { text: 'SyntaxError: Invalid URL', color: 'red' }) + bot.tellraw(selector, { text: e, color: 'red' }) } } }