acceptFriendshipOffer

From SmartBots Developers Docs
Jump to: navigation, search

Accept (or reject) a friendship offer sent by other avatar.

Bot.on("friendship_offer", (event) => {
  Bot.acceptFriendshipOffer(event.avatar_uuid, event.session_id, true);
});

See friendship_offer event for details.


Reference

This command accepts the following parameters:

Variable Required Description


Input:
avatar_uuid yes sender avatar UUID
session_id yes session UUID from the event
accept yes true to accept an offer, false to reject.
Output:
Function returns a Promise with the following data:
success bool true if command completed successfully
error string error string if command has failed

Example

Bot.on("friendship_offer", async function(event) {
  console.log("Got friendship offer from: " + event.avatar_name + "\n\nAccepting now.");
  let response = await Bot.acceptFriendshipOffer(event.avatar_uuid, event.session_id, true);
  if(response.success)
  {
    console.log("Accepted the friendship Offer");
  } else {
    console.log("Rejected the friendship Offer");
    console.error("Error: " + response.error)
  }
});

console.log("Bot is listening, friendship offers");