I've got a twitch bot that interacts with chat quite a lot using Twurple to parse and send messages.
If the bot replies to somebody, sometimes the response isn't desired/necessary/warranted and we want to remove the chat. The problem is that using Twurple's onMessage function doesn't seem to fire when the bot sends a message with ChatClient.say(), so I can't store the message ID to delete later.
chatClient.onMessage( async (channel, user, text, data ) => {
// if conditions met:
chatClient.say(channel, 'My Message');
});
Now, if "My Message" is something we don't want in chat for some reason, the only way to get it out of chat is for the broadcaster to delete it.
I'd like to have an !undo command for all moderators to be able to delete the bot's messages.
My thought was that I could just add an array of messages sent by the bot, and delete the most recent one, but I can't seem to get the ID from twurple if it's a bot message.
I recall tmi.js getting messages from the bot as well, and requiring if( !self ) for functions to not trigger. I don't really want to maintain a twurple client and a tmi client and just use tmi to delete messages via !undo or similar.
Is there a way using twurple alone to get the ID of the messages the bot is sending so I can store and act on those?