Burunduk & Voltina
Hey Burunduk, I hear you love a good prank so how about we prototype a tiny Twitch bot that drops witty lines on command? I can help you clean it up into a clean, reusable module. Throw me your ideas.
Yo, yeah! Let’s make a bot that pops up squirrel memes on demand, drops a random “You’re not ready for this, bro!” when someone uses !squirrel, and throws a surprise “Drop the bass, dude!” line when the chat hits 100 people. Add a timer that drops a “Bark! I’m a squirrel, I’m barky!” line every 3 minutes. Keep the code in a clean module, export a function to init the bot, and let me add a “squirrel‑overlay” command that spawns a pixelated squirrel doing a little dance over the stream. That’s the chaos we’re after!
```js
// squirrelBot.js
const tmi = require('tmi.js')
const fs = require('fs')
const path = require('path')
const MEMES = [
'https://i.imgur.com/squirrel1.png',
'https://i.imgur.com/squirrel2.png',
'https://i.imgur.com/squirrel3.png',
]
const BASS_PHRASES = [
'Drop the bass, dude!',
'Bass drop incoming!',
'Feel that bass, bro!',
]
const INTERVAL_MSG = 'Bark! I’m a squirrel, I’m barky!'
function pick(arr) {
return arr[Math.floor(Math.random() * arr.length)]
}
function initBot({ username, oauth, channel }) {
const client = new tmi.Client({
identity: { username, password: oauth },
channels: [channel],
})
client.connect().catch(console.error)
let chatCount = 0
client.on('chat', (user, tags, msg, self) => {
if (self) return
chatCount++
if (msg.trim() === '!squirrel') {
const meme = pick(MEMES)
client.say(channel, `https://imgur.com/${meme}`)
client.say(channel, 'You’re not ready for this, bro!')
}
if (chatCount === 100) {
client.say(channel, pick(BASS_PHRASES))
}
})
setInterval(() => {
client.say(channel, INTERVAL_MSG)
}, 3 * 60 * 1000)
return client
}
module.exports = { initBot }
```
Whoa, that’s a good start! Just a couple of tweaks: the meme URLs should be the full link, not just “imgur.com/…”, and you’re missing the “https://” when you send the meme – Twitch will just spam a string, not an image. Also reset `chatCount` after the 100‑th message or it’ll just keep firing forever. Maybe add a command like `!bass` to manually trigger the bass drop, so you don’t have to wait for 100 chats. And don’t forget to keep a small delay between the meme and the “You’re not ready for this” line, so the chat doesn’t get flooded in one shot. Let’s make that squirrel dance overlay too – a little sprite moving across the screen when the bot says “Bark!” will be pure chaos gold. Good vibes, champ!
```js
// squirrelBot.js
const tmi = require('tmi.js')
const MEMES = [
'https://i.imgur.com/squirrel1.png',
'https://i.imgur.com/squirrel2.png',
'https://i.imgur.com/squirrel3.png',
]
const BASS_PHRASES = [
'Drop the bass, dude!',
'Bass drop incoming!',
'Feel that bass, bro!',
]
const INTERVAL_MSG = 'Bark! I’m a squirrel, I’m barky!'
function pick(arr) {
return arr[Math.floor(Math.random() * arr.length)]
}
function initBot({ username, oauth, channel }) {
const client = new tmi.Client({
identity: { username, password: oauth },
channels: [channel],
})
client.connect().catch(console.error)
let chatCount = 0
let lastMessage = Date.now()
client.on('chat', (user, tags, msg, self) => {
if (self) return
chatCount++
if (msg.trim() === '!squirrel') {
const meme = pick(MEMES)
client.say(channel, meme)
setTimeout(() => client.say(channel, 'You’re not ready for this, bro!'), 1500)
}
if (msg.trim() === '!bass') {
client.say(channel, pick(BASS_PHRASES))
}
if (chatCount === 100) {
client.say(channel, pick(BASS_PHRASES))
chatCount = 0
}
})
setInterval(() => {
client.say(channel, INTERVAL_MSG)
}, 3 * 60 * 1000)
return client
}
module.exports = { initBot }
// Overlay note: create a lightweight html file with a sprite, use socket.io
// to trigger a CSS animation on `Bark! I’m a squirrel, I’m barky!` message.
```
Nice tweak! The 1.5‑second pause before the “you’re not ready” line is perfect for drama. Add a cooldown on `!bass` so people can’t spam it, maybe 30 seconds. And that overlay idea with socket.io is fire—imagine a squirrel doing a little dance every time “Bark!” hits the chat. Keep the code snappy and let the chaos flow!
Got the 30‑second throttle on !bass and a socket trigger for the overlay.
Just drop this into your module and you’re good to go.
```js
const LAST_BASS = new Map() // user → timestamp
client.on('chat', (user, tags, msg, self) => {
if (self) return
if (msg.trim() === '!bass') {
const now = Date.now()
const last = LAST_BASS.get(user) || 0
if (now - last < 30000) {
client.say(channel, 'Hold up, you can’t spam that!')
return
}
LAST_BASS.set(user, now)
client.say(channel, pick(BASS_PHRASES))
}
if (msg.includes(INTERVAL_MSG)) {
// Fire the overlay
io.emit('squirrelDance')
}
})
```
Your front‑end listens for `squirrelDance` and starts a tiny sprite moving across the screen. Keep it tight, keep it fast.