mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
improve url loading in draw and music playurl
This commit is contained in:
parent
a153a0d4f7
commit
0b21f0ffb8
2 changed files with 11 additions and 7 deletions
|
@ -9,10 +9,11 @@ module.exports = {
|
|||
trusted: 0,
|
||||
usage: '<image url (JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF)>',
|
||||
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' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue