Bots Home
|
Create an App
Wheel Test
Author:
xoxo_caroline1
Description
Source Code
Launch Bot
Current Users
Created by:
Xoxo_Caroline1
// Wheel Of Fortune! // Original idea by SweetDann // Modified by 4science // Version 2.20 // Added custom colors // Made announcement more compact // Added a rare prize // Added a past winners list // Added more options for Multi-Spins // Free spin command. cb.settings_choices = [{ name: 'cost_per_spin', type: 'int', minValue: 1, maxValue: 999, defaultValue: 25, label: 'Cost Per Spin Of The Wheel (1-999): ' }, { name: 'advertise_in_chat', type: 'int', minValue: 1, maxValue: 999, defaultValue: 5, label: 'How Often To Advertise The Bot: (min)' }, { name: 'adTxt', type: 'str', minLength: 1, maxLength: 255, label: 'Custom text to promote the wheel:', defaultValue: 'Spank Wheel Is ACTIVE!', required: false }, { name: 'fontcolor', type: "str", minLength: 6, maxLength: 7, defaultValue: '#FFFFFF', label: 'Pick the color of the font ( default: White #FFFFFF):', required: false }, { name: "bgcolor", type: "str", minLength: 6, maxLength: 7, label: "Background color ( default: Dark Aqua #0B7762):", defaultValue: "#0B7762", required: false }, { name: "modSpin", type: "choice", choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Do you want to allow mods to use the Free spin command when needed?", }, { name: 'spin_exact', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: 'Only spin if the exact token price set for wheel is tipped? (Will disable all the bonus spin parameter)' }, { name: 'multispin_exact', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: 'Only spin if the tip is an exact multiple of cost? (Up to the maximum number of bonus spin)' }, { name: 'multispin_count', type: 'int', minValue: 0, maxValue: 99, defaultValue: 3, label: 'How Many Bonus Spins To Allow Per Tip? (0-99)' }, { name: 'nospin_over', type: 'int', minValue: 0, maxValue: 999, defaultValue: 0, label: 'Prevent the wheel from spinning if the tip amount is over X ( To turn off that feature, leave it at 0)' }, { name: 'nospin', type: 'str', minLength: 1, maxLength: 255, label: 'Exclude specific tip amounts from spinning the wheel. Separate each amount by a comma ( ex: 150, 200, 300).', required: false }, { name: 'rarePrize', type: 'str', minLength: 1, maxLength: 255, label: 'If you want a prize to be rare, enter it here. You can add more than one, separeted by ";".', required: false }, { name: 'rareChance', type: 'int', minValue: 1, maxValue: 500, defaultValue: 99, label: ' Chance of rare prize - 1 in X? (the higher the number, less chance of getting the prize, up to 500)', required: false }, { name: 'rareMin', type: 'int', minValue: 1, maxValue: 100, defaultValue: 15, label: ' Rare will only happen after X roll', required: false }, { name: 'rareBonus', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: 'Should the rare prize only happen on bonus spins to encourage big tippers?' }, { name: 'pos1', type: 'str', minLength: 1, maxLength: 255, label: "Reward #1 " }, { name: 'pos2', type: 'str', minLength: 1, maxLength: 255, label: 'Reward #2 ', required: false }, { name: 'pos3', type: 'str', minLength: 1, maxLength: 255, label: 'Reward #3 ', required: false }, { name: 'pos4', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #4 ', required: false }, { name: 'pos5', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #5 ', required: false }, { name: 'pos6', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #6 ', required: false }, { name: 'pos7', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #7 ', required: false }, { name: 'pos8', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #8 ', required: false }, { name: 'pos9', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #9 ', required: false }, { name: 'pos10', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #10 ', required: false }, { name: 'pos11', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #11 ', required: false }, { name: 'pos12', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #12 ', required: false }, { name: 'pos13', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #13 ', required: false }, { name: 'pos14', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #14 ', required: false }, { name: 'pos15', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #15 ', required: false }, { name: 'pos16', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #16 ', required: false }, { name: 'pos17', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #17 ', required: false }, { name: 'pos18', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #18 ', required: false }, { name: 'pos19', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #19 ', required: false }, { name: 'pos20', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #20 ', required: false }, { name: 'pos21', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #21 ', required: false }, { name: 'pos22', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #22 ', required: false }, { name: 'pos23', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #23 ', required: false }, { name: 'pos24', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #24 ', required: false }, { name: 'pos25', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #25 ', required: false }, { name: 'pos26', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #26 ', required: false }, { name: 'pos27', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #27 ', required: false }, { name: 'pos28', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #28 ', required: false }, { name: 'pos29', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #29 ', required: false }, { name: 'pos30', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #30 ', required: false }, { name: 'pos31', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #31 ', required: false }, { name: 'pos32', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #32 ', required: false }, { name: 'pos33', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #33 ', required: false }, { name: 'pos34', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #34 ', required: false }, { name: 'pos35', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #35 ', required: false }, { name: 'pos36', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #36 ', required: false }, { name: 'pos37', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #37 ', required: false }, { name: 'pos38', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #38 ', required: false }, { name: 'pos39', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #39 ', required: false }, { name: 'pos40', type: 'str', minLength: 0, maxLength: 255, label: 'Reward #40 ', required: false }, ]; var adTxt; var adTxt2 = ""; var rewards = []; var rewardsLength; var rarePrizes = []; var rareLength = 0; var winName = []; var winPrize = []; var winRare = []; var spinCost = cb.settings.cost_per_spin; var spinExact = cb.settings.spin_exact === "Yes"; var maxMulti = cb.settings.multispin_count; var multiExact = cb.settings.multispin_exact === "Yes"; var noSpinOver = cb.settings.nospin_over; var noSpinList = []; var noSpinOn = false; var rareOn = false; var rareChance = 1 / cb.settings.rareChance; var rareMin = cb.settings.rareMin; var rareBonus = cb.settings.rareBonus === "Yes"; var modSpin = cb.settings.modSpin === "Yes"; var background; var foreground; var rollCount = 0; var msgReward; function checkColor(C) { if (/^#[0-9A-F]{6}$/i.test(C)) { return C; } else if (/^[0-9A-F]{6}$/i.test(C)) { return ('#' + C); } else { return ('default'); } } function spinWheel(spinCount, u) { var randomnumber; cb.sendNotice('**** ' + u + ' is spinning The Wheel! ****', "", background, foreground, "bold"); if (rareOn && !rareBonus && rollCount >= rareMin && Math.random() < rareChance) { if (rareLength > 1) { randomnumber = Math.floor(Math.random() * (rareLength)); } else { randomnumber = 0; } cb.sendNotice('**** The Wheel Stop On : ' + rarePrizes[randomnumber] + '!!!! Lucky you!!!', "", background, foreground, "bold"); winName.push(u); winPrize.push(rarePrizes[randomnumber]); winRare.push(true); rollCount++; } else { randomnumber = Math.floor(Math.random() * (rewardsLength)); cb.sendNotice('**** The Wheel Stop On : ' + rewards[randomnumber], "", background, foreground, "bold"); winName.push(u); winPrize.push(rewards[randomnumber]); winRare.push(false); rollCount++; } if (spinCount > 1) { cb.sendNotice('*** ! Multi-Spin Bonus Activated ! ***', "", background, foreground, "bold"); for (let x = 1; x < spinCount; x++) { if (rareLength > 0 && rollCount >= rareMin && Math.random() < rareChance) { if (rareLength > 1) { randomnumber = Math.floor(Math.random() * (rareLength)); } else { randomnumber = 0; } cb.sendNotice('**** Bonus Spin Stop On : ' + rarePrizes[randomnumber] + '!!!! Lucky you!!!', "", background, foreground, "bold"); winName.push(u); winPrize.push(rarePrizes[randomnumber]); winRare.push(true); rollCount++; } else { randomnumber = Math.floor(Math.random() * (rewardsLength)); cb.sendNotice('**** Bonus Spin Stop On : ' + rewards[randomnumber], "", background, foreground, "bold"); winName.push(u); winPrize.push(rewards[randomnumber]); winRare.push(false); rollCount++; } } } cb.sendNotice('**********************************', "", background, foreground); } function advert() { cb.sendNotice(adTxt, "", background, foreground, 'bold'); cb.setTimeout(advert, (cb.settings.advertise_in_chat * 60000)); } function advertCleanUp() { adTxt = cb.settings.adTxt; //Fixing the ad text. if (adTxt == "") { adTxt = 'Wheel of Fortune Is ACTIVE!'; cb.settings.adTxt = 'Wheel of Fortune Is ACTIVE!'; } adTxt += adTxt2; adTxt += '\n Type "/rewards" to get the list of prizes'; } function spamCleanUp(){ if (spinExact){ adTxt2 += '\nThe wheel will only spin for an exact tip of ' + (spinCost) + ' tokens.'; } else{ if (multiExact) { if (maxMulti > 6){ adTxt2 += '\nThe wheel will only spin for multiples of ' + (spinCost) + ' tokens up to ' + maxMulti * spinCost + " tokens."; } else if (maxMulti > 0){ let tipsListFormated; let tipsList = []; for (let x = 1; x <= maxMulti + 1; x++) { tipsList.push(x * spinCost); } let tLl = tipsList.length; cb.log(tLl); if (tLl === 2){ tipsListFormated = tipsList.join( ' or '); } else if(tLl > 2){ tipsListFormated = tipsList.slice(0,-1).join(', ') + " or " + tipsList.slice(-1); } adTxt2 += '\nThe wheel will only spin for tips of '+ tipsListFormated +" tokens."; } else{ adTxt2 += '\nThe wheel will only spin for multiples of ' + (spinCost) + ' tokens.'; } } else{ adTxt2 += '\n Tip ' + (spinCost) + ' tokens to spin the wheel.'; if (maxMulti > 0) { adTxt2 += '\n Bonus spins are enabled. Tip at least ' + (spinCost * 2) + ' tokens to get a bonus spin.' + "\n You can gain " + (maxMulti > 1 ? " up to " : "") + maxMulti + " bonus spin" + (maxMulti > 1 ? "s" : "") + " per tip."; } if (noSpinOver > 0){ adTxt2 += '\n The wheel will not spin for tips over '+ noSpinOver + '.'; } if ( noSpinOn){ adTxt2 += '\n The wheel will not spin for certain specific number. Use /wheelexcluded to see the list.'; } if (rareOn && rareBonus && !spinExact) { adTxt2 += '\nTo have a chance at winning the rare prize, you have to trigger the bonus spin by tipping ' + (spinCost * 2) + ' or more tokens'; } } } } function initAd(){ let msgInit = '--------------------------------' + '\n Wheel of Fortune by 4science' + '\n Version 2.2' + '\n You can now add and remove prizes on the fly.'+ '\n Type "/wheelhelp" to see all the commands.'+ '\n --------------------------------'; msgInit += adTxt2; msgInit += '\n Type /rewards to see all the prizes.' + '\n --------------------------------'; cb.sendNotice(msgInit, "", background, foreground, 'bold'); } function msgRewards(){ rewardsLength = rewards.length; //Lets generate the prize list. msgReward = '**** Here is the list of prizes on the wheel ****\n'; for (let x = 0; x < rewardsLength; x++) { msgReward += String('Reward ' + (x + 1) + ': ' + rewards[x] + '\n'); } if (rareLength > 0) { msgReward += (rareBonus ? "Trigger the bonus spins " : "Spin the wheel ") + "to get a chance of winning " + (rareLength > 1 ? "one of the rare prizes" : "the rare prize") + "\n"; for (let x = 0; x < rareLength; x++) { msgReward += String('Rare reward ' + (x + 1) + ': ' + rarePrizes[x] + '\n'); } } msgReward += '--------------------------------\n'; msgReward += ' Good Luck And Have Fun. \n'; msgReward += '--------------------------------'; } function rareSetup(){ if (cb.settings.rarePrize != "") { if ( spinExact && rareBonus){ cb.sendNotice(' Wheel - Error - Rare prizes are set to only happen on bonus spin and the bot is set to only spin on the exact cost.\n Rare prizes are disabled.', cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); } else if (rareBonus && maxMulti === 0 || rareBonus && spinExact) { cb.sendNotice(' Wheel - Error - Rare is set to only happen on bonus spin and bonus spin is disabled.\n Rare prizes are disabled.', cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); } else { //Splitting the rare prizes let rareTemp = cb.settings.rarePrize; if (rareTemp) { let rareTemp2 = rareTemp.split(";"); for (let i = 0; i < rareTemp2.length; i++) { rarePrizes.push(' :mrstar ' + rareTemp2[i] + ' :mrstar '); } } rareLength = rarePrizes.length; if (rareLength > 0) { rareOn = true; } else { cb.sendNotice("Wheel - Error while setting the rare prizes.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); } } } } function excludeList(){ if ( cb.settings.nospin && !spinExact){ let tempExcl = cb.settings.nospin.split(','); for (let i = 0; i < tempExcl.length; i++){ let tempExcl2 = parseInt(tempExcl[i]); if (tempExcl[i] !== "" && tempExcl[i] !== 0){ if (tempExcl[i].trim().charAt(0) == ">"){ let tempNoSpin = tempExcl2.substr(1); if (isNaN(tempNoSpin) || tempNoSpin < 2){ cb.sendNotice("Wheel - Error while processing the \"No Spin Over\" amount.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); } else if (tempNoSpin > spinCost){ cb.sendNotice("Wheel - Error while processing the \"No Spin Over\" amount. It appears lower than the spin cost.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); } else if (isNaN(noSpinOver)){ noSpinOver = tempNoSpin; } else if (noSpinOver === 0) { noSpinOver = tempNoSpin; } else { cb.sendNotice("Wheel - Error - You have indicated two different values for do not spin over X amount. Picking the smallest one.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); if ( noSpinOver > tempNoSpin){ noSpinOver = tempNoSpin; } } } else if (tempExcl2 === spinCost){ cb.sendNotice("Wheel - Error - You can not exlude the value of a spin.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); } else if (!isNaN(tempExcl2) && tempExcl2 > 0 ) { noSpinList.push(tempExcl2); } else { cb.sendNotice("Wheel - Error while processing the value "+tempExcl[i]+" from the exclude list.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); } } } if (noSpinList.length !== 0){ noSpinList.sort(function(a, b){return a - b}); noSpinOn = true; } } } function logicCheck(){ if (noSpinOver > 0 && !spinExact ){ if (noSpinOver == spinCost && !spinExact){ spinExact = true; } else if (noSpinOver < spinCost){ cb.sendNotice('Wheel - Error while setting up the "don\'t spin over" value. It appears lower than the spin cost. Disabling.', cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); noSpinOver = 0; } else if (spinCost * (maxMulti + 1) > noSpinOver ){ maxMulti = Math.floor( noSpinOver / spinCost) - 1; cb.sendNotice('Wheel - Error - It is impossible to do that many bonus spin for under '+ noSpinOver +' tokens.\n Bonus spin has been set to '+ maxMulti , cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); } } if (spinExact){ if (maxMulti > 0){ cb.sendNotice('Wheel - Error - The wheel is set to only spin on an exact tip of '+spinCost +", the wheel will disable the bonus spin. Make sure this is what you want." , cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); maxMulti = 0; } } } function init() { //Lets check the color foreground = checkColor(cb.settings.fontcolor); if (foreground === 'default') { cb.sendNotice("Wheel - Error while setting the font color. It has to be in a HEX format. Using default value.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); foreground = '#FFFFFF'; } background = checkColor(cb.settings.bgcolor); if (background === 'default') { cb.sendNotice("Wheel - Error while setting the background color. It has to be in a HEX format. Using default value.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); background = '#0B7762'; } //Removing empties. for (let j = 1; j <= 30; j++) { if (cb.settings['pos' + j] !== '') { rewards.push(cb.settings['pos' + j]); } } //Logic Check/re logicCheck(); spamCleanUp(); //Lets exclude some numbers. excludeList(); //Taking care of the rare prizes. rareSetup(); //Lets prep the advert advertCleanUp(); //Advert on start initAd(); //Reward list msgRewards(); //Start the ad cb.setTimeout(advert, (cb.settings.advertise_in_chat * 60000)); } cb.onTip(function(tip) { let spinCount = 0; if (spinExact) { if (tip.amount === spinCost){ spinCount = 1; } } else if (noSpinOver === 0 || noSpinOver > 0 && tip.amount <= noSpinOver) { if ( !noSpinOn || noSpinOn && !cbjs.arrayContains(noSpinList, tip.amount)){ if (!multiExact || multiExact && tip.amount % spinCost === 0) { spinCount = Math.min(Math.floor(tip.amount / spinCost), maxMulti + 1); } } } if (spinCount > 0) { spinWheel(spinCount, tip.from_user); } }); cb.onMessage(function(m) { if (m.m.charAt(0) === "/") { var u = m.user; var msg = m.m.split(" "); var isMod = (cb.room_slug === u || m.is_mod); var noticeMsg; switch (msg[0]) { case "/rewards": case "/srewards": case "/prizes": m['X-Spam'] = true; m.background = '#d9d9d9'; if (isMod && msg['0'] != '/srewards') { u = ''; } cb.sendNotice(msgReward, u, background, foreground, 'bold'); return m; case "/winners": case "/swinners": case "/winner": m['X-Spam'] = true; m.background = '#d9d9d9'; if (isMod && msg['0'] != '/swinners') { u = ''; } var cmdVar1 = msg[1]; var cmdVar2 = parseInt(msg[1]); var nameNum; var l = winName.length; if (l === 0) { cb.sendNotice('**** No one has won a prize yet ****', u, background, foreground); return m; } if (isNaN(cmdVar1) && cmdVar1 !== undefined) { if (cmdVar1 === "all" || cmdVar1 === "All") { if (l > 100) { noticeMsg = '**** Here is the list of the last 100 winners! ****\n'; nameNum = l - 100; } else { noticeMsg = '**** Here is the list of all the winners! ****\n'; nameNum = 0; } for (let x = nameNum; x < l; x++) { noticeMsg += 'Roll #' + (x + 1) + ': ' + winName[x] + ' won ' + winPrize[x] + '\n'; } noticeMsg += '**************************************'; cb.sendNotice(noticeMsg, u, background, foreground); return m; } else if (cbjs.arrayContains(winName, cmdVar1)) { noticeMsg = '**** Here is the list of all the prizes ' + cmdVar1 + ' won! ****\n'; var prizesWon = []; for (let x = 0; x < l; x++) { if (cmdVar1 === winName[x]) { prizesWon.push(winPrize[x]); } } noticeMsg += prizesWon.join(', '); noticeMsg += '\n**************************************'; cb.sendNotice(noticeMsg, u, background, foreground); } else { cb.sendNotice('Unable to find ' + cmdVar1 + ' on the winners list.', u, background, foreground); } } else { if (cmdVar1 === undefined) { cmdVar2 = 10; } if (cmdVar2 <= 0) { cb.sendNotice('**** Here are the last 0 winners! :p', u, background, foreground); return m; } if (l < cmdVar2) { cmdVar2 = l; } noticeMsg = '**** Here are the last ' + cmdVar2 + ' winners! **** \n'; for (let x = l - cmdVar2; x < l; x++) { noticeMsg += 'Roll #' + (x + 1) + ': ' + winName[x] + ' won ' + winPrize[x] + '\n'; } noticeMsg += '**************************************'; cb.sendNotice(noticeMsg, u, background, foreground); } return m; case "/whowon": case "/swhowon": m['X-Spam'] = true; m.background = '#d9d9d9'; if (isMod && msg['0'] !== '/swhowon') { u = ''; } let winners = []; l = winName.length; if (msg[1] === 'rare') { for (let x = 0; x < l; x++) { if (winRare[x] === true) { winners.push(winName[x] + " won " + winPrize[x]); } } if (winners.length > 0) { noticeMsg = '**** Here is everyone who won a rare prize! **** \n'; noticeMsg += winners.join('\n'); noticeMsg += '\n**************************************'; } else { noticeMsg = '**** No one has won a rare prize yet. **** '; } } else { cmdVar1 = parseInt(msg[1]) - 1; if (cmdVar1 >= 0){ for (let x = 0; x < l; x++) { if (winPrize[x] === rewards[cmdVar1]) { winners.push(winName[x]); } } if (winners.length > 0) { noticeMsg = '**** Here is everyone who won ' + rewards[cmdVar1] + '! **** \n'; noticeMsg += winners.join(', '); noticeMsg += '\n**************************************'; } else { noticeMsg = '**** No one has won ' + rewards[cmdVar1] + ' yet. **** '; } } else { noticeMsg ='You have to indicate the position of the reward. Use /rewards to see the list. You can use "/whowon rare" for the rare prize.'; } } cb.sendNotice(noticeMsg, u, background, foreground); return m; case "/addprize": { m['X-Spam'] = true; m.background = '#d9d9d9'; if (!isMod) { cb.sendNotice("Only mods and broadcasters can use this command.", u, "#FFFFFF", "#FF0000"); } else { let label; if (!msg[1]) { cb.sendNotice("You need to include a label for that option.", u, "#FFFFFF", "#FF0000"); return m; } for (let j = 1; j < msg.length; j++) { if (j === 1) { label = msg[j]; } else { label += " " + msg[j]; } } cb.sendNotice("Wheel to Broadcaster - " + (u === cb.room_slug ? "You" : u) + ' added "' + label + '" to the list of prizes.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); cb.sendNotice("Wheel to mods - " + u + ' added "' + label + '" to the list of prizes.', "", "#FFFFFF", "#FF0000", "bold", "red"); rewards.push(label); msgRewards(); } return m; } case "/removeprize": case "/deleteprize": case "/delprize": { m['X-Spam'] = true; m.background = '#d9d9d9'; if (!isMod) { cb.sendNotice("Only mods and broadcasters can use this command.", u, "#FFFFFF", "#FF0000"); } else { if (rewardsLength == 0){ cb.sendNotice("The list of prizes is already empty.", u, "#FFFFFF", "#FF0000"); return m; } let position = parseInt(msg[1]) - 1; if (!position && position != 0) { cb.sendNotice("You need to indicate the position of the prize you want to remove. Type /rewards to see each position.", u, "#FFFFFF", "#FF0000"); return m; } if (position >= rewardsLength ) { cb.log ("Rewardlengt :"+ rewardsLength); cb.log ("oositi:"+position); cb.sendNotice("It seems like there isn't that many prizes on the wheel. Type /rewards to see each position.", u, "#FFFFFF", "#FF0000"); return m; } cb.sendNotice("Wheel to Broadcaster - " + (u === cb.room_slug ? "You" : u) + ' removed "' + rewards[position] + '" from the list of prizes.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); cb.sendNotice("Wheel to mods - " + u + ' removed "' + rewards[position] + '" from the list of prizes.', "", "#FFFFFF", "#FF0000", "bold", "red"); rewards.splice( position , 1); msgRewards(); } return m; } case "/addrare": { m['X-Spam'] = true; m.background = '#d9d9d9'; if (!isMod) { cb.sendNotice("Only mods and broadcasters can use this command.", u, "#FFFFFF", "#FF0000"); } else { let label; if (!msg[1]) { cb.sendNotice("You need to include a label for that option.", u, "#FFFFFF", "#FF0000"); return m; } for (let j = 1; j < msg.length; j++) { if (j === 1) { label = msg[j]; } else { label += " " + msg[j]; } } cb.sendNotice("Wheel to Broadcaster - " + (u === cb.room_slug ? "You" : u) + ' added "' + label + '" to the list of rare prizes.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); cb.sendNotice("Wheel to mods - " + u + ' added "' + label + '" to the list of rare prizes.', "", "#FFFFFF", "#FF0000", "bold", "red"); rarePrizes.push(' :mrstar ' + label + ' :mrstar '); rareLength = rarePrizes.length; if (rareLength > 0) { rareOn = true; } else { cb.sendNotice("Wheel - Error while setting the rare prizes.", cb.room_slug, "#FFFFFF", "#FF0000", 'bold'); } msgRewards(); } return m; } case "/removerare": case "/deleterare": case "/delrare": { m['X-Spam'] = true; m.background = '#d9d9d9'; if (!isMod) { cb.sendNotice("Only mods and broadcasters can use this command.", u, "#FFFFFF", "#FF0000"); } else { if (rareLength == 0){ cb.sendNotice("The list of rare prizes is already empty.", u, "#FFFFFF", "#FF0000"); return m; } let position = parseInt(msg[1]) - 1; if (!position && position != 0) { cb.sendNotice("You need to indicate the position of the rare prize you want to remove. Type /rewards to see each position.", u, "#FFFFFF", "#FF0000"); return m; } if (position >= rareLength ) { cb.sendNotice("It seems like there isn't that many rare prizes on the wheel. Type /rewards to see each position.", u, "#FFFFFF", "#FF0000"); return m; } cb.sendNotice("Wheel to Broadcaster - " + (u === cb.room_slug ? "You" : u) + ' removed "' + rarePrizes[position] + '" from the list of rare prizes.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); cb.sendNotice("Wheel to mods - " + u + ' removed "' + rarePrizes[position] + '" from the list of rare prizes.', "", "#FFFFFF", "#FF0000", "bold", "red"); rarePrizes.splice( position , 1); rareLength = rarePrizes.length; if (rareLength == 0){ rareOn = false; } msgRewards(); } return m; } case "/wheelexcluded": m['X-Spam'] = true; m.background = '#d9d9d9'; if (noSpinOn ){ cb.sendNotice('The wheel will not spin for these values: ' + noSpinList.join(', ') + (noSpinOver > 0 ? " and everything over " + noSpinOver +"." : "."), u, "#FFFFFF", "#FF0000", "bold"); } else if (noSpinOver > 0){ cb.sendNotice("The wheel will not spin for values over " + noSpinOver +".", u, "#FFFFFF", "#FF0000", "bold"); } return m; case "/freespin": m['X-Spam'] = true; m.background = '#d9d9d9'; if (isMod) { if (modSpin || u === cb.room_slug) { if (u !== cb.room_slug) { cb.sendNotice(u + ' is using the free spin function.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); } if (msg[1] !== undefined) { u = msg[1]; } spinWheel(1, u); } else { cb.sendNotice('**** This command is not enable for mods ****', u, "#FFFFFF", "#FF0000"); } } else { cb.sendNotice('**** Only mods and broadcasters can use this command. ****', u, "#FFFFFF", "#FF0000"); } return m; case "/spincost": m['X-Spam'] = true; m.background = '#d9d9d9'; if (isMod) { cmdVar1 = parseInt(msg[1]); if (cmdVar1 > 0) { spinCost = cmdVar1; if (u !== cb.room_slug) { cb.sendNotice(u + ' changed the price to spin the wheel.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); } cb.sendNotice('**** The price to spin the wheel is now ' + spinCost + " token" + (spinCost > 1 ? "s" : "") + "!", "", background, foreground, "bold"); advertCleanUp(); } else { cb.sendNotice('**** You have to indicate a new price. ex: "/spincost 30" ', u, background, foreground); } } else { cb.sendNotice('**** Only mods and broadcasters can use this command. ****', u, "#FFFFFF", "#FF0000"); } return m; case "/wheeltxtcolor": m['X-Spam'] = true; m.background = '#d9d9d9'; if (isMod || u === '4science') { let fg = checkColor(msg[1]); if (msg[1] !== 'default' && fg === 'default') { cb.sendNotice('**** Error - The color must be in HEX format (ex: #FFFFFF). ****', u, "#FFFFFF", "#FF0000"); return m; } else if (msg[1] === 'default') { foreground = '#FFFFFF'; cb.sendNotice('**** The color has been reset to default', u, background, foreground); } else { foreground = fg; cb.sendNotice('**** The color has been changed to ' + foreground, u, background, foreground); } if (u !== cb.room_slug) { cb.sendNotice(u + ' changed the color of the wheel.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); cb.sendNotice('**** The color has been changed to ' + foreground, cb.room_slug, background, foreground); } } else { cb.sendNotice('**** Only mods and broadcasters can use this command. ****', u, "#FFFFFF", "#FF0000"); } return m; case "/wheelbgcolor": m['X-Spam'] = true; m.background = '#d9d9d9'; if (isMod || u === '4science') { let bg = checkColor(msg[1]); if (msg[1] !== 'default' && bg === 'default') { cb.sendNotice('**** Error - The color must be in HEX format (ex: #FFFFFF). ****', u, "#FFFFFF", "#FF0000"); return m; } else if (msg[1] === 'default') { background = '#0B7762'; cb.sendNotice('**** The color has been reset to default', u, background, foreground); } else { background = bg; cb.sendNotice('**** The color has been changed to ' + background, u, background, foreground); } if (u !== cb.room_slug) { cb.sendNotice(u + ' changed the color of the wheel.', cb.room_slug, "#FFFFFF", "#FF0000", "bold"); cb.sendNotice('**** The color has been changed to ' + background, cb.room_slug, background, foreground); } } else { cb.sendNotice('**** Only mods and broadcasters can use this command. ****', u, "#FFFFFF", "#FF0000"); } return m; case "/wheelhelp": m['X-Spam'] = true; m.background = '#d9d9d9'; cb.sendNotice( "Here are the commands available for the Wheel of Fortune.\n" + "- /rewards: Show all the prizes in chat.\n" + "- /winners: Show the last 10 winners.\n" + "- /winners X: Show the last X winners.\n" + "- /winners all: Show all the requests (up to 100).\n" + "- /whowon X: Show everyone who won the prize at position X.\n" + "- /whowon rare: Show everyone who won a rare prize.\n" + "- /freespin - Spin the wheel if you are out of ideas or if you just want to reward someone. Will only work if you are the broadcaster, can be turn on for mods.\n"+ "- /freespin namehere - Will spin the wheel but will use the namehere as the username. Useful to have the right name in the winning list at the end.\n"+ '- /addprize Y: Add a prize name Y to the wheel.\n' + "- /removeprize X: Removes the prize at position X.\n" + "- /addrare Y: Add a rare prize name Y to the wheel.\n" + "- /removerare X: Remove the rare prize at position X.", u); return m; } } return m; }); cb.onEnter(function(user) { var u = user.user; var msgOnEnter = "--------------------------------" + "\n Hello " + u + ", " + cb.settings.adTxt; msgOnEnter += adTxt2; msgOnEnter += '\n Type /rewards to see all the prizes.' + "\n --------------------------------"; cb.sendNotice(msgOnEnter, u, background, foreground, 'bold'); }); init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.