tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.54k stars 216 forks source link

periodic error log #548

Closed Khyretos closed 11 months ago

Khyretos commented 11 months ago

Actual behaviour: after connecting it periodically logs an error, without doing anything.

Expected behaviour: no error logs if no actions are made

Error log: https://api.twitch.tv/kraken/chat/emoticon_images?emotesets=0,42,19194,300374282 image

(anonymous) @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1449
_updateEmoteset @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1441
(anonymous) @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1437
setEmotesetTimer @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1437
(anonymous) @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1464
_updateEmoteset @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1464
(anonymous) @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1437
setEmotesetTimer @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1437
(anonymous) @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1464
_updateEmoteset @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1464
(anonymous) @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1437
setEmotesetTimer @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1437
(anonymous) @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1464
_updateEmoteset @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1464
(anonymous) @ D:\repos\LoquendoBotV2\node_modules\tmi.js\lib\client.js:1437

Configuration

AlcaDesign commented 11 months ago

Set options.skipUpdatingEmotesets to true

const client = new tmi.Client({
    options: {
        skipUpdatingEmotesets: true
    }
});
Khyretos commented 11 months ago

i am still getting the error. image

for some reason it says its already declared.

here is my code;

/* global showChatMessage, getPostTime, playVoice, playSound, settings, env, twitchTemplate */

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

// Create a client with the specified options
const client = new tmi.Client({
    skipUpdatingEmotesets: true,
    identity: {
        username: settings.TWITCH.USERNAME,
        password: `oauth:${settings.TWITCH.OAUTH_TOKEN}`,
    },
    channels: [settings.TWITCH.CHANNEL_NAME],
});

client.connect().catch(console.error);

client.on('message', (channel, tags, message, self) => {
    if (self) {
        return;
    } // Ignore messages sent by the bot itself

    // Filter out custom Twitch emotes from the message
    const emotes = tags.emotes || {};
    const emoteValues = Object.values(emotes);

    let fileteredMessage = message;
    const slicedPart = [];

    emoteValues.forEach((entry) => {
        const [start, end] = entry[0].split('-');
        slicedPart.push(fileteredMessage.slice(parseInt(start), parseInt(end) + 1));
    });

    slicedPart.forEach((entry) => {
        fileteredMessage = fileteredMessage.replace(entry, '');
    });

    if (message !== '') {
        // Log the received message
        console.log(`${tags['display-name']}: ${fileteredMessage}`);
    }
});

class Twitch {
    // Filter out custom Twitch emotes from the message
    static sendMessage(message) {
        client.say(settings.TWITCH.CHANNEL_NAME, message);
    }
}

const twitch = new Twitch();
module.exports = twitch;
AlcaDesign commented 11 months ago

Check my example again. It needs to go under the options group.

Khyretos commented 11 months ago

Check my example again. It needs to go under the options group.

my bad!