I'm writing a simple discord bot that just spews out a randomly selected response from a list but I keep running into the same Discord API error.
Here's my code.
client.on('messageCreate', message => {
const responses = [['Yehaw', 'Yehaw!!', 'Yahee', 'Cowboy shit']];
let randomNumber = Math.floor(Math.random() * Math.floor(responses.length));
let randomMessage = responses[randomNumber];
if (message.author.bot) return;
if (message.content.includes ('Yehaw'))
message.channel.send(randomMessage);
});
Here's my error message
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:\Users\User\Desktop\DiscordBot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\User\Desktop\DiscordBot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async TextChannel.send (C:\Users\User\Desktop\DiscordBot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:176:15) {
method: 'post', path: '/channels/976509969199407185/messages', code: 50006, httpStatus: 400,
I've tried a few variations on the message selection method but they all throw the same error