I'm making a grogu discord bot and want to send a random comic picture in an embed, when someone uses g!comic
.
So far I have this:
client.on('message', message =>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command === 'ping'){
client.commands.get('ping').execute(message, args);
}else if (command === 'comic') {
const random = new Discord.MessageEmbed()
.setTitle('Here is your random grogu comic')
.setImage(image)
message.channel.send(random);
}
});
The problem is, when I test it, it always sends the same picture/link and I don't know how to fix it.
This is where the images are stored:
const images = ["https://i.pinimg.com/originals/4d/2e/f3/4d2ef3052fab7b613733f56cd224118b.jpg", "https://red.elbenwald.de/media/image/a5/f8/e9/E1064005_1_600x600.jpg", "https://i.pinimg.com/736x/29/43/39/2943397229b5fb42cf12e8a1302d1821.jpg", "https://i.kym-cdn.com/photos/images/original/001/755/387/09f.jpg" ];
const image = images[Math.floor(Math.random() * images.length)];
*update: after restarting the bot, it shows a different picture, but it posts always the same until I restart the bot
question from:
https://stackoverflow.com/questions/65936266/discord-js-random-image-is-always-the-same 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…