Closed PhilippHeuer closed 4 years ago
Oops, I'll have to update the docs on this. You need to wait until everything is setup before you can send requests. Just move your calls so they happen after the connected
event is fired.
const RustPlus = require('rustplus-api');
var rustplus = new RustPlus('ip', port, '<steamid>', '<token>');
rustplus.on('message', (message) => {
console.log("message received: " + JSON.stringify(message));
});
// when connected to rust server
rustplus.on('connected', () => {
rustplus.getEntityInfo(1234567, (message) => {
console.log("getEntityInfo response message: " + JSON.stringify(message));
return true;
});
rustplus.sendTeamMessage('Hello World!', (message) => {
console.log(message);
});
});
Thanks a lot for the quick response, it works like this :)
Hey, i wanted to play around with this a little and made a new project in which i created a index.js and run the require command from the readme - it looks like this:
But whenever i call a function that would trigger a request i'm getting this error before it's even executed:
Do you know what i'm doing wrong?