i need a way my bot can respond with a random response like and 8ball command

Tags: , ,



Preferably through a const such as const responses = ["response1", "response2", response3"] using discord.js v12.2.0.

Answer

// Creating an array with responses.
const Responses = ["Response1", "Response2", "Response3", "Response4"];

// Picking a random response and logging it.
console.log(Responses[Math.floor(Math.random() * Responses.length)]);


Source: stackoverflow