question

jdeegz avatar image
jdeegz asked

How can I send PlayFab statistic (leaderboard) updated to Discord?

Hi!

I am a dev learning how to program. I have followed a tutorial that allows me to use the Revisions view to create a Cloud Script function that will send a Discord message to my channel when there is a new user registration.

I am trying to figure out how to build upon this concept by creating a function that is triggered by the event: player_statistic_changed assigned to fire off the function:

handlers.newScorePosted = function(args){ var contentBody = { "content": "New Score from" + DisplayName + ": " + StatisticValue + "on mission: " + StatisticName + "!" }; var url = "https://discord.com/api/webhooks/1196549715450404964/xU-6unDu20fXf-XhlQABZC5SfkVc6YoQm2I7-DFUX1XzZU22k2Kh1DBfgYMtbYF93Xjo"; var method = "post"; var contentType = "application/json"; var headers = {}; var responseString = http.request(url,method,JSON.stringify(contentBody),contentType,headers); }

But I am not recieving any messages in Discord. I'm taking shots in the dark to try and figure out how to pass dynamic content into my message's string.

Any help would be greatly appreciated.

P.S. Would it be possible to determine if the score (value) is in the top-10 of a leaderboard, and only send a Discord message if so?

PlayStream
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers