{ "author": "Arthur Pacaud (arthuro555)", "description": "Allows adding discord rich presence to your games. Only works on Windows/Mac/Linux exports. \nYou can get more infos on each field via [the discord docs](https://discord.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields).", "extensionNamespace": "", "fullName": "Discord rich presence (Windows, Mac, Linux)", "helpPath": "", "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWRpc2NvcmQiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMjIsMjRMMTYuNzUsMTlMMTcuMzgsMjFINC41QTIuNSwyLjUgMCAwLDEgMiwxOC41VjMuNUEyLjUsMi41IDAgMCwxIDQuNSwxSDE5LjVBMi41LDIuNSAwIDAsMSAyMiwzLjVWMjRNMTIsNi44QzkuMzIsNi44IDcuNDQsNy45NSA3LjQ0LDcuOTVDOC40Nyw3LjAzIDEwLjI3LDYuNSAxMC4yNyw2LjVMMTAuMSw2LjMzQzguNDEsNi4zNiA2Ljg4LDcuNTMgNi44OCw3LjUzQzUuMTYsMTEuMTIgNS4yNywxNC4yMiA1LjI3LDE0LjIyQzYuNjcsMTYuMDMgOC43NSwxNS45IDguNzUsMTUuOUw5LjQ2LDE1QzguMjEsMTQuNzMgNy40MiwxMy42MiA3LjQyLDEzLjYyQzcuNDIsMTMuNjIgOS4zLDE0LjkgMTIsMTQuOUMxNC43LDE0LjkgMTYuNTgsMTMuNjIgMTYuNTgsMTMuNjJDMTYuNTgsMTMuNjIgMTUuNzksMTQuNzMgMTQuNTQsMTVMMTUuMjUsMTUuOUMxNS4yNSwxNS45IDE3LjMzLDE2LjAzIDE4LjczLDE0LjIyQzE4LjczLDE0LjIyIDE4Ljg0LDExLjEyIDE3LjEyLDcuNTNDMTcuMTIsNy41MyAxNS41OSw2LjM2IDEzLjksNi4zM0wxMy43Myw2LjVDMTMuNzMsNi41IDE1LjUzLDcuMDMgMTYuNTYsNy45NUMxNi41Niw3Ljk1IDE0LjY4LDYuOCAxMiw2LjhNOS45MywxMC41OUMxMC41OCwxMC41OSAxMS4xMSwxMS4xNiAxMS4xLDExLjg2QzExLjEsMTIuNTUgMTAuNTgsMTMuMTMgOS45MywxMy4xM0M5LjI5LDEzLjEzIDguNzcsMTIuNTUgOC43NywxMS44NkM4Ljc3LDExLjE2IDkuMjgsMTAuNTkgOS45MywxMC41OU0xNC4xLDEwLjU5QzE0Ljc1LDEwLjU5IDE1LjI3LDExLjE2IDE1LjI3LDExLjg2QzE1LjI3LDEyLjU1IDE0Ljc1LDEzLjEzIDE0LjEsMTMuMTNDMTMuNDYsMTMuMTMgMTIuOTQsMTIuNTUgMTIuOTQsMTEuODZDMTIuOTQsMTEuMTYgMTMuNDUsMTAuNTkgMTQuMSwxMC41OVoiIC8+PC9zdmc+", "name": "DiscordRichPresence", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/discord.svg", "shortDescription": "Adds discord rich presence to your games.", "version": "1.0.0", "tags": [ "discord", "rich", "presence", "integration", "status" ], "dependencies": [ { "exportName": "discord-rich-presence", "name": "Discord SDK", "type": "npm", "version": "0.0.8" } ], "eventsFunctions": [ { "description": "", "fullName": "", "functionType": "Action", "name": "onFirstSceneLoaded", "private": false, "sentence": "", "events": [ { "disabled": false, "folded": false, "type": "BuiltinCommonInstructions::JsCode", "inlineCode": "gdjs.evtTools.drp = {\n client: null,\n joinRequest: null,\n join: null,\n spectate: null,\n error: null,\n};\n", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false } ], "parameters": [], "objectGroups": [] }, { "description": "", "fullName": "", "functionType": "Action", "name": "onScenePostEvents", "private": false, "sentence": "", "events": [ { "disabled": false, "folded": false, "type": "BuiltinCommonInstructions::JsCode", "inlineCode": "gdjs.evtTools.drp.joinRequest = null;\ngdjs.evtTools.drp.join = null;\ngdjs.evtTools.drp.spectate = null;\ngdjs.evtTools.drp.error = null;\n", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false } ], "parameters": [], "objectGroups": [] }, { "description": "Attempts to connect to discord if it is installed, and initialize rich presence.", "fullName": "Initialize rich presence", "functionType": "Action", "name": "ConnectToDiscord", "private": false, "sentence": "Initialize rich presence with ID _PARAM1_", "events": [ { "disabled": false, "folded": false, "type": "BuiltinCommonInstructions::JsCode", "inlineCode": "const electron = runtimeScene.getGame().getRenderer().getElectron();\nif (!electron) return;\nconst DRP = electron.remote.require(\"discord-rich-presence\");\n\nif (gdjs.evtTools.drp.client) gdjs.evtTools.drp.client.disconnect();\ngdjs.evtTools.drp.client = new DRP(eventsFunctionContext.getArgument(\"clientId\"))\n .on(\"join\", (secret) => (gdjs.evtTools.drp.join = secret))\n .on(\"spectate\", (secret) => (gdjs.evtTools.drp.spectate = secret))\n .on(\"joinRequest\", (user) => (gdjs.evtTools.drp.joinRequest = user, console.log(user)))\n .on(\"error\", (e) => (gdjs.evtTools.drp.error = e));\n\nwindow.addEventListener(\"beforeunload\", () => gdjs.evtTools.drp.client.disconnect());\n", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false } ], "parameters": [ { "codeOnly": false, "defaultValue": "", "description": "The discord client ID", "longDescription": "", "name": "clientId", "optional": false, "supplementaryInformation": "", "type": "string" } ], "objectGroups": [] }, { "description": "Update the data in the rich presence. See the discord documentation for more info on each field.", "fullName": "Update rich presence", "functionType": "Action", "name": "UpdateRichPresence", "private": false, "sentence": "Update rich presence to state _PARAM1_", "events": [ { "disabled": false, "folded": false, "type": "BuiltinCommonInstructions::JsCode", "inlineCode": "if (!gdjs.evtTools.drp.client) return;\n\nconst payload = {\n state: undefined,\n details: undefined,\n startTimestamp: undefined,\n endTimestamp: undefined,\n largeImageKey: undefined,\n largeImageText: undefined,\n smallImageKey: undefined,\n smallImageText: undefined,\n partyId: undefined,\n partySize: undefined,\n partyMax: undefined,\n matchSecret: undefined,\n joinSecret: undefined,\n spectateSecret: undefined,\n};\n\nfor (const i in payload) {\n payload[i] = eventsFunctionContext.getArgument(i);\n if (payload[i] === 0 || payload[i] === \"\") delete payload[i];\n};\n\ngdjs.evtTools.drp.client.updatePresence(payload);\n", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": true } ], "parameters": [ { "codeOnly": false, "defaultValue": "", "description": "The current state", "longDescription": "", "name": "state", "optional": false, "supplementaryInformation": "", "type": "string" }, { "codeOnly": false, "defaultValue": "", "description": "The details of the current state", "longDescription": "", "name": "details", "optional": false, "supplementaryInformation": "", "type": "string" }, { "codeOnly": false, "defaultValue": "", "description": "The timstamp of the start of the match", "longDescription": "", "name": "startTimestamp", "optional": false, "supplementaryInformation": "", "type": "expression" }, { "codeOnly": false, "defaultValue": "", "description": "The timestamp of the end of the match", "longDescription": "", "name": "endTimestamp", "optional": false, "supplementaryInformation": "", "type": "expression" }, { "codeOnly": false, "defaultValue": "", "description": "The name of the big image", "longDescription": "", "name": "largeImageKey", "optional": false, "supplementaryInformation": "", "type": "string" }, { "codeOnly": false, "defaultValue": "", "description": "The text of the large image", "longDescription": "", "name": "largeImageText", "optional": false, "supplementaryInformation": "", "type": "string" }, { "codeOnly": false, "defaultValue": "", "description": "The name of the small image", "longDescription": "", "name": "smallImageKey", "optional": false, "supplementaryInformation": "", "type": "string" }, { "codeOnly": false, "defaultValue": "", "description": "The text of the small image", "longDescription": "", "name": "smallImageText", "optional": false, "supplementaryInformation": "", "type": "string" }, { "codeOnly": false, "defaultValue": "", "description": "An identifier of the player's party, lobby, or group\t", "longDescription": "", "name": "partyId", "optional": false, "supplementaryInformation": "", "type": "string" }, { "codeOnly": false, "defaultValue": "", "description": "The current size of the player's party, lobby, or group", "longDescription": "", "name": "partySize", "optional": false, "supplementaryInformation": "", "type": "expression" }, { "codeOnly": false, "defaultValue": "", "description": "The maximum size of the player's party, lobby, or group\t", "longDescription": "", "name": "partyMax", "optional": false, "supplementaryInformation": "", "type": "expression" }, { "codeOnly": false, "defaultValue": "", "description": "A unique payload to give to the game when clicking the spectate button", "longDescription": "", "name": "spectateSecret", "optional": false, "supplementaryInformation": "", "type": "string" }, { "codeOnly": false, "defaultValue": "", "description": "A unique payload to give to the game when clicking the join button", "longDescription": "", "name": "joinSecret", "optional": false, "supplementaryInformation": "", "type": "string" } ], "objectGroups": [] }, { "description": "Triggers once when a join request from another user was received.", "fullName": "On join request", "functionType": "Condition", "name": "OnJoinRequest", "private": false, "sentence": "Join request received", "events": [ { "disabled": false, "folded": false, "type": "BuiltinCommonInstructions::JsCode", "inlineCode": "eventsFunctionContext.returnValue = gdjs.evtTools.drp.joinRequest !== null;\r\n", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false } ], "parameters": [], "objectGroups": [] }, { "description": "Triggers once when a joining a game.", "fullName": "On join game", "functionType": "Condition", "name": "OnJoin", "private": false, "sentence": "Joining a game", "events": [ { "disabled": false, "folded": false, "type": "BuiltinCommonInstructions::JsCode", "inlineCode": "eventsFunctionContext.returnValue = gdjs.evtTools.drp.join !== null;\r\n", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false } ], "parameters": [], "objectGroups": [] }, { "description": "Triggers once when a join request was received.", "fullName": "On join request", "functionType": "Condition", "name": "OnSpectate", "private": false, "sentence": "Join request received", "events": [ { "disabled": false, "folded": false, "type": "BuiltinCommonInstructions::JsCode", "inlineCode": "eventsFunctionContext.returnValue = gdjs.evtTools.drp.spectate !== null;\r\n", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false } ], "parameters": [], "objectGroups": [] }, { "description": "Triggers once when a join request was received.", "fullName": "On join request", "functionType": "Condition", "name": "OnError", "private": false, "sentence": "Join request received", "events": [ { "disabled": false, "folded": false, "type": "BuiltinCommonInstructions::JsCode", "inlineCode": "eventsFunctionContext.returnValue = gdjs.evtTools.drp.error !== null;\r\n", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false } ], "parameters": [], "objectGroups": [] }, { "description": "Answers the last recieved join request.", "fullName": "Answer a join request", "functionType": "Action", "name": "AnswerJoinRequest", "private": false, "sentence": "Answer join request with _PARAM1_", "events": [ { "disabled": false, "folded": false, "type": "BuiltinCommonInstructions::JsCode", "inlineCode": "if (gdjs.evtTools.drp.client && gdjs.evtTools.drp.joinRequest)\r\n gdjs.evtTools.drp.client.reply(\r\n gdjs.evtTools.drp.joinRequest,\r\n eventsFunctionContext.getArgument(\"accept\") ? \"YES\" : \"NO\"\r\n );\r\n", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false } ], "parameters": [ { "codeOnly": false, "defaultValue": "", "description": "Accept the request?", "longDescription": "", "name": "accept", "optional": false, "supplementaryInformation": "", "type": "yesorno" } ], "objectGroups": [] } ], "eventsBasedBehaviors": [] }