Hello, this is my first time attempting to create a discord bot.
I want the bot to send a random message to a channel at a set interval
The code i use is this :
client.on(‘ready’, () => {
var channelname = client.channels.find(channel => channel.id === ‘’)
var answers = [“a”, “b”, “c”, “d”, “e”]
var randomAnswer = answers[Math.floor(Math.random() * answers.length)]
console.log("The bot is logged in.")
setInterval(() => {
channelname.send(randomAnswer)
}, 3000)
What i want it to do is pick a random message every X seconds from var answers and send it to specified channel.
What it ends up doing with this code is pick a random message once and then it repeats the same message every X seconds
How can i make it pick each time a different random message?
(i removed channel id from the code on purpose for this post)