add clipboards

This commit is contained in:
2025-04-04 10:02:13 +02:00
parent 2d94d51ec7
commit a7430c3b67
4 changed files with 29 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
import { HelixUser } from "@twurple/api"
import { changeBalance, getInventory, updateInventory } from "../lib/userHelper"
import { timeout, addTimeoutToDB, vulnerableUsers } from "./timeoutHelper"
import api from "./api"
import api, { broadcasterApi } from "./api"
export const ITEMS = ['blaster', 'silverbullet', 'grenade', 'tnt', 'clipboard', 'lootbox']
@@ -149,3 +149,13 @@ function shuffle(arrayold: any[]) {
}
return array
}
export async function useClipboard(broadcasterId: string, user: HelixUser, question: string, say: (arg0: string) => Promise<void>) {
const tempapi = broadcasterApi ?? api
const polldata = await tempapi.polls.getPolls(broadcasterId)
if (polldata.data.length > 0) {await say('Can\'t have two polls active at once.'); return}
const itemResult = await changeItemCount(user, 'clipboard')
if (!itemResult.result && itemResult.reason === 'negative') { await say('You have no clipboards mandoooYikes'); return }
await tempapi.polls.createPoll(broadcasterId, { choices: ['Yes', 'No'], duration: 120, title: question })
await say(`${user.name} used a clipboard! They have ${itemResult.count} clipboard${itemResult.count === 1 ? '' : 's'} remaining`)
}