edqx / node-scratch-client

A client for the scratch 3.0 website.
16 stars 7 forks source link

Cannot set cloud variables #1

Open WilsontheWolf opened 5 years ago

WilsontheWolf commented 5 years ago

I cannot set a cloud variable using this. The error I get is


(node:4069) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'set' of undefined
    at CloudSession.setVariable (/rbd/pnpm-volume/e38efa70-1bc7-452e-891e-f660e6a03dfd/node_modules/.registry.npmjs.org/node-scratch-client/1.3.7/node_modules/node-scratch-client/src/Struct/CloudSession.js:35:27)
at cloud.connect.then (/app/server.js:41:9)
(node:4069) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4069) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
code:```js
const config = require("./config.json");
const scratch = require("node-scratch-client");

const Client = new scratch.Client({
  username: config.username,
  password: config.password
});

Client.login().then(() => {
  let cloud = Client.session.createCloudSession(221003966);

  cloud.connect().then(() => {
    cloud.on("set", variable => {
      console.log("Variable \""+variable.name+"\" changed to " + variable.value);

    });
  cloud.setVariable('☁ Test', 'Test')//seting her. ☁ Test exists
  });
});```