tmijs / tmi.js

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

Bot says [object Object] instead of a username #20

Closed Hay1tsme closed 9 years ago

Hay1tsme commented 9 years ago

I think I've already wrote about this... When trying to make a command to timeout users who say a certain word, I get [object Object] instead of their username

client.addListener('chat', function (channel, username, message) {
    //timeout users who get salty about giveawyas
    else if (message.indexOf('reroll') === 0){
        client.say(channel, "/t  " + username + " 30")
        client.say(channel, "Please no PJSalt about the giveaways " + username + ". 30 second Timeout.")
    }
});

Here's the responce:

[11:28pm] info: [#rbrockers] <rbrockers>: reroll
[11:28pm] info: [#rbrockers] Executing command: /t [object Object] 30
[11:28pm] info: [#rbrockers] <rbrockbot>: Please no PJSalt about the giveaways [
object Object]. 30 second Timeout.
[11:28pm] warn: Could not parse NOTICE from tmi.twitch.tv:
[11:28pm] warn: @msg-id=unrecognized_cmd :tmi.twitch.tv NOTICE #rbrockers :Unrec
ognized command: /t
celluj34 commented 9 years ago

That's because it is an object. You want to use something like:

var name = user["display-name"] || user["username"];

AlcaDesign commented 9 years ago

Refer to your duplicate post: https://github.com/twitch-irc/twitch-irc/issues/118#issuecomment-122632952

Hay1tsme commented 9 years ago

Thank you, sorry