Hi everyone,
I know this has probably been posted before but I cant find any further information as the pages that answer don’t show up for me.
I am trying to keep track of my specific chatters and how many times they have checked in my Twitch chat. I am doing this for a prize at the end of the month so basically im thinking like a simple !checkin command user specific that would track how many times that user has checked in for the month’s streams. I understand the private and public token is needed, just not sure how many commands i would need to use or do for this to be user specific counting. Any help is appreciated!
You can use the Nightbot Counter API to keep track of check-ins and Google Apps Script (free) to ensure users can only check-in once per day.
- Go to Google Apps Script.
- Create a new project.
- Paste this code:
const NAMESPACE = "checkinbot";
function doGet(e) {
const user = e.parameter.user;
if (!user) return ContentService.createTextOutput("❌ User not defined");
const KEY = `user-${user.toLowerCase()}`;
const baseUrl = `https://api.counterapi.dev/v1/${NAMESPACE}/${KEY}`;
let count = 0;
let lastUpdate = null;
try {
const response = UrlFetchApp.fetch(baseUrl);
const data = JSON.parse(response.getContentText());
count = data.count;
lastUpdate = new Date(data.updated_at);
} catch (error) {
const errorText = error.toString();
if (errorText.includes("record not found")) {
UrlFetchApp.fetch(`${baseUrl}/up`);
return ContentService.createTextOutput(`✅ @${user}, first check-in recorded! You now have 1 check-in.`);
} else {
return ContentService.createTextOutput(`⚠️ Error checking your check-in: ${errorText}`);
}
}
const now = new Date();
if (lastUpdate && lastUpdate.toDateString() === now.toDateString()) {
return ContentService.createTextOutput(`🛑 @${user}, you have already checked in today.`);
}
UrlFetchApp.fetch(`${baseUrl}/up`);
return ContentService.createTextOutput(`✅ @${user}, check-in recorded! You now have ${count + 1} check-ins.`);
}
- Click Deploy → Manage deployments → New deployment
Type: Web app
Access: Anyone
Copy the generated URL and add a custom command in Nightbot:
!addcom !checkin $(urlfetch https://script.google.com/macros/s/XXX/exec?user=$(user))
Replace https://script.google.com/… with your actual script URL.