Untitled
unknown
javascript
a year ago
2.9 kB
8
Indexable
var config = { betAmount: { value: 20, type: 'text', label: 'Amount to bet (in bits)' }, cashOut: { value: 1.10, type: 'text', label: 'Cash out multiplier' }, discordWebhook: { value: '', type: 'text', label: 'Discord Webhook URL' } }; var gamesToWait = Math.floor(Math.random() * (6 - 3 + 1)) + 3; // Function to send a message to Discord function sendMessageToDiscord(message) { const webhookURL = config.discordWebhook.value; if (!webhookURL) { console.log('Discord Webhook URL not provided.'); return; } fetch(webhookURL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ content: message }) }) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } console.log('Message sent to Discord.'); }) .catch(error => { console.error('Error sending message to Discord:', error); }); } // Function to initialize the bot function initializeBot() { console.log('Waiting for ' + gamesToWait + ' games before placing the first bet.'); // Send initial message when the bot starts sendMessageToDiscord('Bot started. Waiting for ' + gamesToWait + ' games before placing the first bet.'); } // Counter for tracking games var gameCounter = 0; engine.on('GAME_STARTING', function() { gameCounter++; if (gameCounter >= gamesToWait) { var betAmountBits = parseFloat(config.betAmount.value); var betAmountSatoshis = betAmountBits * 100; // Convert bits to satoshis var cashOut = parseFloat(config.cashOut.value); if (betAmountSatoshis > 0 && betAmountSatoshis <= userInfo.balance) { engine.bet(betAmountSatoshis, cashOut); console.log('Bet placed: ' + betAmountBits + ' bits with cash out at ' + cashOut + 'x.'); } else { console.log('Invalid bet amount or insufficient balance to place bet.'); sendMessageToDiscord('Invalid bet amount or insufficient balance to place bet.'); } // Reset game counter gameCounter = 0; } }); engine.on('GAME_ENDED', function() { var lastGame = engine.history.first(); var message = ''; if (lastGame.wager) { if (lastGame.cashedAt) { message = 'Won last game! Cashed out at ' + lastGame.cashedAt + 'x.'; } else { message = 'Lost last game. Game busted at ' + lastGame.bust + 'x.'; } } else { message = 'No bet was placed in the last game.'; } sendMessageToDiscord(message); }); // Initialize the bot initializeBot();
Editor is loading...
Leave a Comment