Home > database >  Discord.js Send a message every X seconds with Client.on('ready', () => { });
Discord.js Send a message every X seconds with Client.on('ready', () => { });

Time:04-30

I would like to send a message every X seconds and that the user who reacts first gives him 10 coins.

The problem does not come from the system of coins, it is correctly executed.

This code does not work and tells me Cannot read properties of undefined (reading 'send')

I know this is because I'm not using Client.on('message', message => { }) but I really wish it would go through ready is there any way to do it differently? Can you help me to correct this code?

Client.on('ready', () => {
    const fs = require('fs');

    const userCoin = JSON.parse(fs.readFileSync('Storage/userCoin.json', 'utf-8'));

    const channel2up22 = Client.channels.cache.get('935549530210983976');

                    //Random Drop
    const doSomething = () => {
        let Embed = new Discord.MessageEmbed()
                    .setTitle("Wild Gift            
  • Related