Skip to content

Instantly share code, notes, and snippets.

@chuckreynolds
Created October 10, 2019 21:36
Show Gist options
  • Save chuckreynolds/a61dcf35e521a247c64b91f608c526b3 to your computer and use it in GitHub Desktop.
Save chuckreynolds/a61dcf35e521a247c64b91f608c526b3 to your computer and use it in GitHub Desktop.
snippet for TMI.js to log subscriber and/or founder badge via Alca https://discordapp.com/channels/325552783787032576/477487607379656716/631960904606547980
client.on('message', (channel, tags, message, self) => {
if(self) return;
const { badges, 'badge-info': badgeInfo } = tags;
let isSubscriber = false;
let monthsSubbed = -1;
if(badges) {
isSubscriber = badges.subscriber || badges.founder;
if(isSubscriber) {
monthsSubbed = badgeInfo.subscriber || badgeInfo.founder;
}
}
if(isSubscriber) {
console.log(`${tags.username} is a subscriber for ${monthsSubbed} month(s).`);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment