I’ve pored over the Twitch IRC tags and commands in the docs here, but I’m having a tough time cracking this. I have two questions:
What is the syntax for getting a message’s ID in Twitch chat? Here’s what I’ve tried. For the moment I’m just outputting it to chat when I’m not streaming, for testing purposes:
Actually, I tried message[“msg-id”] before I tried the others, and it also returned undefined. And message.msg-id causes the Node.js script to abort, as you have to use brackets and quotes when there is a hyphen involved.
I added console.log(message) and typed a test message into chat, but all that showed up in the log was the text of the message itself.
BTW, the reason I didn’t include the msg-id tag in my OP is that it appears that it would only return a sort of status name rather than a discreet id of the specific message. Am I interpreting this correctly?
Yeah, I deleted and reposted as a direct reply to you, and it went through right after you replied. And yes, it’s tmi.js. Thanks for the suggestion re library. I just joined the discord per the link here.
Yup! I tried adding a console.log(user.id) statement and then typing test messages into my chat. Each time I did, it returned a number like this: c85cc3bb-3635-5184-a728-5f7b081f2b92. So I’m thinking that this must be the actual ID of the message, as it changed with each message I typed.
Next step is to figure out how to delete said message. I did find this at line 177 of commands.js in the lib directory of tmi.js:
// Delete a specific message on a channel
deletemessage: function deletemessage(channel, messageUUID) {
channel = _.channel(channel);
// Send the command to the server and race the Promise against a delay..
return this._sendCommand(this._getPromiseDelay(), channel, `/delete ${messageUUID}`, (resolve, reject) => {
// Received _promiseDeletemessage event, resolve or reject..
this.once("_promiseDeletemessage", (err) => {
if (!err) { resolve([channel]); }
else { reject(err); }
});
});
},
I just need to get my syntax right for requiring commands.js in my bot in order to use this. I know that’s another library question, and I will ask it in the Discord. Posting it here anyway, just in case someone knows.