0

I'm new to making discord bots. This bot is supposed to send an image every one to three hours. It only sends one and then it no longer does anything.

This is the code:

const Discord = require("discord.js");
const {Client, GatewayIntentBits} = Discord;
const client = new Discord.Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages
  ]
});
    
client.on("ready", () => {
  console.log("Bot is ready!");
  
  // canal a mandar la imagen
  const channel = client.channels.cache.get("channel id");
  
  const imageUrl = "image here"; 
  // numero random entre 1 y 3 horas (en milisegundos)
  const randomDelay = Math.floor(Math.random() * (3 * 3600 * 1000 - 3600 * 1000)) + 3600 * 1000;
  
  // Delay de imagen
  setTimeout(() => {
    channel.send("message", { files: [imageUrl] });
  }, randomDelay);
});

client.login("TOKEN");
Zsolt Meszaros
  • 21,961
  • 19
  • 54
  • 57
Lemon
  • 1

0 Answers0