Difference between revisions of "Bot Playground/Events/balance changed"

From SmartBots Developers Docs
Jump to: navigation, search
(Created page with "{{DISPLAYTITLE:balance_changed}} <onlyinclude>Fires when bot receives or payd money</onlyinclude> <syntaxhighlight lang="javascript"> Bot.on("balance_changed", function(event...")
 
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:
  
 
{{API Event Table}}
 
{{API Event Table}}
{{API Variable Group|Output}}
+
{{API Variable Group|''event'' object properties}}
 
{{API Variable|name}}The name of the event in this case balance_changed
 
{{API Variable|name}}The name of the event in this case balance_changed
 
{{API Variable|amount}}The amount which was paid or received.
 
{{API Variable|amount}}The amount which was paid or received.
{{API Variable|direction}}The direction of the money flow, can be INCOMING or OUTGOING
+
{{API Variable|direction}}The direction of the money flow, can be:
 +
INITIAL: bot has logged in, balance is known now<br>
 +
INCOMING: money has arrived<br>
 +
OUTGOING: money has been sent
 
{{API Variable|source}}The UUID of the money sender
 
{{API Variable|source}}The UUID of the money sender
 
{{API Variable|destination}}The UUID of the money receiver
 
{{API Variable|destination}}The UUID of the money receiver
 
{{API Variable|balance}}The current balance after the payment
 
{{API Variable|balance}}The current balance after the payment
 
{{API Variable|trx_type}}The transaction type
 
{{API Variable|trx_type}}The transaction type
 +
{{API Variable|comment}}Transaction comment
 +
{{API Variable|transaction}}Transaction UUID
  
 
{{API Variables Table End}}
 
{{API Variables Table End}}

Latest revision as of 19:12, 10 September 2022

Fires when bot receives or payd money

Bot.on("balance_changed", function(event) { ... });

Reference

This event comes with the following event object:

Variable Required Description
event object properties:
name The name of the event in this case balance_changed
amount The amount which was paid or received.
direction The direction of the money flow, can be:

INITIAL: bot has logged in, balance is known now
INCOMING: money has arrived
OUTGOING: money has been sent

source The UUID of the money sender
destination The UUID of the money receiver
balance The current balance after the payment
trx_type The transaction type
comment Transaction comment
transaction Transaction UUID

Example

Bot.on("balance_changed", function(event) {
	console.log("Balance changed, my new balance is: " + event.balance);
});

console.log("Bot is listening to payments");