Hi all. I'm trying to make my own twitch chatbot in the spirit of Linux DIY'ing and masochism; having my own bot's name is waaaaay cooler than a common bot with user-friendly UIs and their plethora of engaging and powerful features, apparently.
TL;DR: How do I min-max learning how to translate the Twitch API documentation for Node.JS? Exact questions at the bottom.
My progress so far on July 9, 2023:
I set up a bot successfully using this article but with tweaks:
https://www.section.io/engineering-education/build-a-twitch-chatbot-in-nodejs/
Archive .org capture here: https://web.archive.org/web/20230000000000*/https://www.section.io/engineering-education/build-a-twitch-chatbot-in-nodejs/
Changes:
- Skipped the streamyard stuff because, who cares, I have OBS
- I added identity tags under the connection configurations because I kept getting errors in my terminal that my bot couldn't write to chat anonymously (I've never seen anonymous chatting, why the hell is this in the suggested code). Connection config section of the .js file now looks like this:
const client = new tmi.Client({
options: { debug: true, messagesLogLevel: "info" },
connection: {
reconnect: true,
secure: true
},
identity: {
username:${process.env.TWITCH_USERNAME}
,
password:oauth:${process.env.TWITCH_OAUTH}
},
channels: [${process.env.TWITCH_CHANNEL}
]
});`
- Kind of nested (is that the right word?) in the switch section, I removed the entire "Upvote" and "Cheers" shenanigans because, for some reason with the suggested code in the article, it replied like "FireEmoji unknown_user unknown_user, you have been upvoted!" to every single line of chat, lmao. The bot would reply to "Watsup dorks" with something like "FiReEmOji @Watsup dorks, you have been upvoted!".
- Also kind of nested in the switch section, I added the random number generator example given in other people's tutorials around the internet and formatted it similarly to the article's method of checking messages like so:
// When user enters "!rolldice" in chat, bot returns random number between 1 and 20.
case '!rolldice':
client.say(channel,${tags.username} rolled a ${Math.floor(Math.random()*20)+1}!
);
break;
If you would like me to revisit that article's suggested code as-is and be more specific with my errors encountered, I'd be happy to oblidge upon request.
Questions I hope to answer someday:
How do I get my bot to see if a message has a hyperlink, then delete that message?
How do I set up a whitelist database of usernames for my bot to reference so they could post whatever links?
How do I get my bot to timeout people who have entered trigger words in chat?
How do I get my bot to change other chatters' name colors in chat?
What is the next best source of internet community I can go to for advice on Twitch API use? (It's July 2023 at the moment, and giving Reddit traffic to learn to make moderator bots is, IMO, a bit ironic).
How can I learn to translate the Twitch API commands to javascript like this? Is there a library that can tell me in close-to-plain-english that explains things like "client.say() means this, this is how you can use it, and X things must be specified in these brackets for client.say" etc.?
To min-max your learning process and efficiently translate the Twitch API documentation for Node.js, you can follow these steps:
Understand the Twitch API: Familiarize yourself with the Twitch API documentation. Read through the official Twitch API documentation thoroughly to gain an understanding of its features, endpoints, and authentication methods.
Identify the key areas: Based on your questions, identify the specific areas of the Twitch API documentation that you need to focus on. For example, you mentioned message moderation, whitelist database, timeouts, and chat color changes.
Break down the questions: Break down each question into smaller, more manageable tasks. For example:
a. How do I get my bot to see if a message has a hyperlink, then delete that message? b. How do I set up a whitelist database of usernames for my bot to reference so they could post whatever links? c. How do I get my bot to timeout people who have entered trigger words in chat? d. How do I get my bot to change other chatters’ name colors in chat?
Search for relevant documentation: Use the Twitch API documentation, forums, and other reliable resources to search for specific endpoints, methods, or events related to the questions you have. Look for examples and code snippets that demonstrate how to achieve the desired functionality.
Explore existing libraries and packages: Check if there are existing Node.js libraries or packages that provide abstractions or wrappers for the Twitch API. These libraries can simplify the process of integrating Twitch functionality into your Node.js application and may provide clearer explanations and usage instructions.
Join developer communities: Engage with developer communities specific to Twitch or Node.js. Participate in forums, Discord channels, or developer communities dedicated to Twitch API or Node.js development. These communities can provide valuable insights, tips, and advice based on their experiences.
Experiment and iterate: As you learn, experiment with the Twitch API, Node.js code, and the modifications you want to make to your bot. Iterate on your implementation, test different approaches, and troubleshoot any issues that arise.
Document your progress: Maintain clear and organized documentation of your progress. Take notes, create code samples, or store snippets that you find useful. This documentation will serve as a reference for future development and troubleshooting.
Remember, learning and mastering any API takes time and practice. By breaking down your questions, seeking relevant documentation, exploring communities, and experimenting with code, you'll gradually build your understanding and proficiency in working with the Twitch API using Node.js.