Apps Home
|
Create an App
Poll or Voting Bot
Author:
seattlescarletjojo
Description
Source Code
Launch App
Current Users
Created by:
Seattlescarletjojo
// Settings for the poll cb.settings_choices = [ {name: 'option1', type: 'str', minLength: 1, maxLength: 256, defaultValue: 'Outfit Change', label: 'Option 1'}, {name: 'option2', type: 'str', minLength: 1, maxLength: 256, defaultValue: 'Toy Play', label: 'Option 2'}, {name: 'vote_price', type: 'int', minValue: 1, maxValue: 1000, defaultValue: 50, label: 'Tokens Per Vote'} ]; // Variables to track votes let votes = {option1: 0, option2: 0}; // Announce the poll function announcePoll() { cb.sendNotice("🗳️ Vote now! Type !vote1 for " + cb.settings.option1 + " or !vote2 for " + cb.settings.option2 + ". Each vote costs " + cb.settings.vote_price + " tokens."); } // Function to handle tipping votes cb.onTip(function(tip) { let voteCount = Math.floor(tip['amount'] / cb.settings.vote_price); if (tip['message'].includes("!vote1")) { votes.option1 += voteCount; cb.sendNotice(tip['from_user'] + " voted " + voteCount + " time(s) for " + cb.settings.option1); } else if (tip['message'].includes("!vote2")) { votes.option2 += voteCount; cb.sendNotice(tip['from_user'] + " voted " + voteCount + " time(s) for " + cb.settings.option2); } // Announce current vote count cb.sendNotice("Current Votes: " + cb.settings.option1 + ": " + votes.option1 + ", " + cb.settings.option2 + ": " + votes.option2); }); // Handle chat commands for voting (free option) cb.onMessage(function(msg) { let message = msg['m']; if (message === "!vote1") { votes.option1 += 1; cb.sendNotice(msg['user'] + " voted for " + cb.settings.option1); } else if (message === "!vote2") { votes.option2 += 1; cb.sendNotice(msg['user'] + " voted for " + cb.settings.option2); } // Announce current vote count cb.sendNotice("Current Votes: " + cb.settings.option1 + ": " + votes.option1 + ", " + cb.settings.option2 + ": " + votes.option2); return msg; }); // Announce the poll periodically cb.setTimeout(announcePoll, 30000); // Announce poll every 30 seconds // Announce the final results and reset the poll function endPoll() { let winner = votes.option1 > votes.option2 ? cb.settings.option1 : cb.settings.option2; cb.sendNotice("Poll ended! 🎉 The winner is: " + winner + " with " + (votes.option1 > votes.option2 ? votes.option1 : votes.option2) + " votes!"); votes = {option1: 0, option2: 0}; // Reset votes cb.setTimeout(announcePoll, 10000); // Start a new poll after 10 seconds } cb.setTimeout(endPoll, 180000); // End the poll every 3 minutes
© Copyright Freesexcam 2011- 2024. All Rights Reserved.