getGlobalObject()

getGlobalObject([callback])

Gets the global object of your account. What is the global object?

— callback (Function(err, object))

Function called when finished (optional).

  • err (String): null or a description of what went wrong if something went wrong.
  • object (PlainObject): the content of your globalObject, if the globalObject is not filled then object will be an empty object {}.
/*Bot launched with globalObject:
{
  "name": "nick",
  "age": 2 
}
*/

try {
  const object = await buster.getGlobalObject()
  console.log("The name is", object.name, "and the age is", object.age)
  //This will print "The name is nick and the age is 2"
} catch (err) {
  console.log("Could not get the global object:", err)
}
/*Bot launched with globalObject:
{
  "name": "nick",
  "age": 2 
}
*/

buster.getGlobalObject()
.then((object) => {
  console.log("The name is", object.name, "and the age is", object.age)
  //This will print "The name is nick and the age is 2"
})
.catch((err) => {
  console.log("Could not get the global object:", err)
})
/*Bot launched with globalObject:
{
  "name": "nick",
  "age": 2 
}
*/

buster.getGlobalObject(function(err, object) {
  if (err) {
    console.log("Could not get the global object:", err)
  } else {
    console.log("The name is", object.name, "and the age is", object.age)
    //This will print "The name is nick and the age is 2"
  }
})