tmijs / tmi.js

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

Twitch Bot Color Problem #306

Closed yagizdo closed 6 years ago

yagizdo commented 6 years ago

Hi again. The commands I set are written in the color of the bot as if it were written with / me. !süre writing my command in normal color.

Color coded code codes and chat screenshots : Chat ss : image Code ss : image

My first command is the same color as the bot. But this code I wrote separately is normal. I want to turn the colored one back to normal.

Problem-free !süre command screenshots : Chat ss : image

Uptime codes : `client.on('message', (channel, userstate, message, fromSelf) => { if(fromSelf || message[0] !== '!') { return; }

userstate.name = userstate['display-name'] || userstate.username;

let chan = channel.slice(1),
    params = message.split(' '),
    commandName = params.shift().slice(1).toLowerCase(),
    hasParams = params.length > 0,
    perms = {
        mod: userstate.mod,
        broadcaster: userstate['user-id'] === userstate['room-id']
        //broadcaster: 'broadcaster' in userstate.badges
    },
    reply = msg => client.say(channel, msg);

perms.modUp = perms.mod || perms.broadcaster;

if(commandName === 'time') {
    let d = new Date();
    reply(d.toLocaleString());
}
else if(commandName === 'created') {
    let target = userstate.username;
    if(hasParams && perms.modUp) {
        target = params[0];
    }

    kraken({
        url: `users/${target}`,
        qs: {
            _: Math.random() * 1000000
        }
    }, (err, res, body) => {
        if(err) {
            console.log('ERROR', err);
            reply('Errror');
            return;
        }
        else if(res.statusCode !== 200) {
            reply('User not found');
            return;
        }

        let timestamp = new Date(body.created_at).getTime(),
            created = countdown(timestamp, Date.now(), 158),
            name = body.display_name || body.name,
            message = `${userstate.name}, ${name} was created ` +
                `${created.toString()} ago.`;

        reply(message);
    });
}
else if(commandName === 'süre') {
    let target = chan;
    if(hasParams && perms.modUp) {
        target = params[0];
    }

    kraken({
        url: `streams/${target}`,
        qs: {
            _: Math.random() * 1000000
        }
    }, (err, res, body) => {
        if(err) {
            console.log('ERROR', err);
            reply('Errror');
            return;
        }
        else if(res.statusCode !== 200) {
            reply('User not found');
            return;
        }

        if(body.stream === null) {
            reply(`${target} is offline. :(`);
            return;
        }

        let timestamp = new Date(body.stream.created_at).getTime(),
            uptime = countdown(timestamp, Date.now(), 158),
            message = `${uptime.minutes} dakika ${uptime.seconds} saniyedir yayındayız! `;

        reply(message);
    });
}

});`

AlcaDesign commented 6 years ago

The client.action method is /me and client.say is normal.