Quiero crear un bot que seleccione una imagen aleatoria de una serie de enlaces, pero no sé qué tiene de malo, aquí está el código y el error.
const arg = message.content.slice(prefix.lenght).split(/ +/); const command = arg.shift().toLowerCase(); if(command === 'jtoh'){ const rando_imgs = [ 'https://media.giphy.com/media/CZpro4AZHs436/giphy.gif', 'https://media.giphy.com/media/CZpro4AZHs436/giphy2.gif', 'https://media.giphy.com/media/CZpro4AZHs436/giphy3.gif', ] message.channel.send( { file: rando_imgs[Math.floor(Math.random() * rando_imgs.length)] }); }El error es que el método send() acepta un objeto con una propiedad de files (no file ). Esto debería ser una matriz donde puede agregar su imagen aleatoria. Lo siguiente funcionará para usted:
if (command === 'jtoh') { const rando_imgs = [ 'https://media.giphy.com/media/CZpro4AZHs436/giphy.gif', 'https://media.giphy.com/media/CZpro4AZHs436/giphy2.gif', 'https://media.giphy.com/media/CZpro4AZHs436/giphy3.gif', ]; message.channel.send({ files: [rando_imgs[Math.floor(Math.random() * rando_imgs.length)]], }); } Si desea mostrar el mensaje, puede usar la propiedad de content en su lugar. En este caso, no tiene que enviar una matriz.
message.channel.send({ content: rando_imgs[Math.floor(Math.random() * rando_imgs.length)], }); Además, hay un error tipográfico; prefix.lenght debe ser prefix.length .
const arg = message.content.slice(prefix.length).split(/ +/);