Почему не работает твич бот?

Нашёл твич бота а рассылка в чате не работает.

Ошибка:

Trying to send a scheduled message
C:\Users\User\Desktop\Twitch bot\index.js:75
        client.say(notifications.channel, notifications.messages[notifications.next_message]);
                                                                ^
TypeError: Cannot read properties of undefined (reading '0')
    at Timeout.timeout [as _onTimeout] (C:\Users\User\Desktop\Twitch bot\index.js:75:65)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)

Код:

const tmi = require('tmi.js'),
    fs = require('fs');

const config = {
    token: "токен",
    prefix: "!",
    channel_name: "nick",
    debug: true
};

var notifications = {
    message: ["Сообщение"],
    next_message: 0,
    chat_activity: 0
};


const client = new tmi.Client({
    options: {
        debug: config.debug
    },
    connection: {
        secure: true,
        reconnect: true
    },
    channels: [config.channel_name],
    identity: {
        username: "nickbot",
        password: config.token
    }
});

client.commands = new Map();
client.connect();
loadCommands();

client.on('message', (channel, tags, message, self) => {
    notifications.chat_activity++;
    notifications.channel = channel;

    if (!message.startsWith(config.prefix) || self) return;
    const args = message.slice(config.prefix.length).trim().split(/ +/g);
    const command = args.shift();

    if (command == "hi") {
        return client.say(channel, `@${tags.username}, hello to you too!`)
    }

    const cmd = client.commands.get(`${command}`);
    if (cmd) {
        cmd.messageExecute(client, {
            channel: channel,
            tags: tags,
            message: message,
            command: command,
            args: args
        });
    }
});

async function loadCommands() {
    const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
    for (const file of commandFiles) {
        const command = require(`./commands/${file}`);
        client.commands.set(command.help.name, command);
    }

    if (config.debug) console.log(`Loaded ${commandFiles.length} commands.`)
}

const timeout = function() {
    if (config.debug) console.log(`Trying to send a scheduled message`);
    if (notifications.chat_activity >= 20 && notifications.channel != undefined) {
        notifications.chat_activity = 0;
        client.say(notifications.channel, notifications.messages[notifications.next_message]);
        if (config.debug) console.log(`Message sent: [${notifications.messages[notifications.next_message]}]`);

        notifications.next_message++;
        if (notifications.next_message >= notifications.messages.length) {
            notifications.next_message = 0;
        }
    }

    setTimeout(timeout, 1000 * 60 * 5); // 5 minutes
}
timeout();

Ответы (0 шт):