Skip to content
← Back to Community
Music-bot-1
Profile icon
IdioticFruit

So im trying to code the music bot but the problem is that everytime I type in the command, the output in the console goes like this

https://preview.redd.it/0j6iou5vrmt71.jpg?auto=webp&s=a85f1ea321d9ca84fc4fae68b8483e93cfed90fd This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason: DiscordAPIError: Cannot send an empty message at RequestHandler.execute (/home/runner/Music-bot-1/node_modules/discord.js/src/rest/RequestHandler.js:298:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async RequestHandler.push (/home/runner/Music-bot-1/node_modules/discord.js/src/rest/RequestHandler.js:50:14) at async TextChannel.send (/home/runner/Music-bot-1/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:172:15)

Heres my code

const https = require('https'); const Discord = require('discord.js'); const url = 'https://www.reddit.com/r/meme/hot/.json?limit=100' module.exports = { name: 'meme', aliases: [], utilisation: '{prefix}meme', execute(cleint, message, args) { https.get(url, (result) => { var body = '' result.on('data', (chunk) => { body += chunk }) result.on('end', () => { var response = JSON.parse(body) var index = response.data.children[Math.floor(Math.random() * 99) + 1].data if (index.post_hint !== 'image') { var text = index.selftext const textembed = new Discord.MessageEmbed() .setTitle(subRedditName) .setColor(9384170) .setDescription(`[${title}](${link})\n\n${text}`) .setURL(`https://reddit.com/${subRedditName}`) message.channel.send(textembed) } var image = index.preview.images[0].source.url.replace('&', '&') var title = index.title var link = 'https://reddit.com' + index.permalink var subRedditName = index.subreddit_name_prefixed if (index.post_hint !== 'image') { const textembed = new Discord.RichEmbed() .setTitle(subRedditName) .setColor(9384170) .setDescription(`[${title}](${link})\n\n${text}`) .setURL(`https://reddit.com/${subRedditName}`) message.channel.send(textembed) } console.log(image); const imageembed = new Discord.MessageEmbed() .setTitle(subRedditName) .setImage(image) .setColor(9384170) .setDescription(`[${title}](${link})`) .setURL(`https://reddit.com/${subRedditName}`) message.channel.send(imageembed) }).on('error', function (e) { console.log('Got an error: ', e) }) }) }, }
Voters
Profile icon
alan29042008
Profile icon
IdioticFruit