Closed ICostaEx closed 7 years ago
It does have to be logged in but you should initialize after the login is complete, so move "var onMessage = rbx.onMessage()" into the then function along with everything else.
On Jun 19, 2017, at 09:17, ICostaEx notifications@github.com wrote:
When using events (such as onMessage) does the 'bot' need to be logged in like so:
var rbx = require('roblox-js');
var onMessage = rbx.onMessage(); rbx.login('','') .then(function (info) { onMessage.on('data', function (message){ onMessage.emit('handle', message, true, function() { const body = 'sdhdk'; rbx.message(message.sender.name,'Dear user',body) .then(function (info){ console.log('Worked') }).catch(function(err){ console.error(err.stack); }); }).catch(function(err){ console.error(err.stack); }); }).catch(function(err){ console.error(err.stack); }); }).catch(function(err){ console.error(err.stack); });
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Alright, now the only error I am getting is;
Unhandled rejection TypeError: Cannot read property 'id' of undefined
at /root/node_modules/roblox-js/lib/event/onMessage.js:19:33
at tryCatcher (/root/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/root/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/root/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/root/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/root/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/root/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/root/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/root/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)
Ok you are still doing a couple things wrong, read up on EventEmitters when you have a chance because you are not using them correctly. Something like this would work:
var rbx = require('roblox-js');
function handle (err) {
console.error(err.stack);
}
rbx.login('*****','*****')
.then(function () {
var onMessage = rbx.onMessage();
onMessage.on('data', function (message) {
rbx.message(message.sender.userId, 'Dear user', 'Test')
.then(function () {
console.log('Worked')
}).catch(handle);
});
onMessage.on('error', handle);
}).catch(handle);
I still get the same error...
var onMessage = rbx.onMessage();
onMessage.on('data', function (message) {
const body = 'Thank you for your message,\nhowever this account is an automation and is not managed by a person.\n\nIf your message is important feel free to message TheeDeer.\n\nRegards,\nInfius Integration';
rbx.message(message.sender.name,'Dear user',body)
.then(function () {
console.log('Worked')
}).catch(handle);
});
onMessage.on('error', handle);
ERROR:
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
0|bot | TypeError: Cannot read property 'id' of undefined
0|bot | at /root/node_modules/roblox-js/lib/event/onMessage.js:19:33
0|bot | at tryCatcher (/root/node_modules/bluebird/js/release/util.js:16:23)
0|bot | at Promise._settlePromiseFromHandler (/root/node_modules/bluebird/js/release/promise.js:512:31)
0|bot | at Promise._settlePromise (/root/node_modules/bluebird/js/release/promise.js:569:18)
0|bot | at Promise._settlePromise0 (/root/node_modules/bluebird/js/release/promise.js:614:10)
0|bot | at Promise._settlePromises (/root/node_modules/bluebird/js/release/promise.js:693:18)
0|bot | at Async._drainQueue (/root/node_modules/bluebird/js/release/async.js:133:16)
0|bot | at Async._drainQueues (/root/node_modules/bluebird/js/release/async.js:143:10)
0|bot | at Immediate.Async.drainQueues (/root/node_modules/bluebird/js/release/async.js:17:14)
0|bot | at runCallback (timers.js:800:20)
0|bot | at tryOnImmediate (timers.js:762:5)
0|bot | at processImmediate [as _immediateCallback] (timers.js:733:5)
0|bot | (node:28641) DeprecationWarning: TextChannel#sendMessage: use TextChannel#send instead
0|bot | (node:28641) DeprecationWarning: EvaluatedPermissions#hasPermission is deprecated, use Permissions#has instead
Not trying to be spoonfed here but I cant find my way around this error, onShout() works perfectly fine for me...
First of all you are not logging in, make sure to log in and put onMessage in a .then
exactly as I showed in my reply. Secondly you send messages based on ID, not name. If you actually read the reply I posted it shows that you have to use message.sender.userId
to send the message.
I am logging in, I just did not put it in my snippit. and the error is not coming from the message.sender.name because If I comment that part out I still get the error. It's coming from rbx.onMessage as the error states.
No need to get hostile... Just trying to get some help here.
var rbx = require('roblox-js');
function handle (err) {
console.error(err.stack);
}
rbx.login('***','***')
.then(function () {
var onMessage = rbx.onMessage();
onMessage.on('data', function (message) {
console.log(message);
});
onMessage.on('error', handle);
}).catch(handle);
still throws the error:
Unhandled rejection TypeError: Cannot read property 'id' of undefined
at /root/node_modules/roblox-js/lib/event/onMessage.js:19:33
at tryCatcher (/root/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/root/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/root/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/root/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/root/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/root/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/root/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/root/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)
Add these (to the login .then function) and give me the output:
rbx.getCurrentUser().then(console.log);
rbx.getMessages().then(console.log);
Start: 0; End: 1
Unhandled rejection TypeError: Cannot read property 'id' of undefined
at /root/node_modules/roblox-js/lib/event/onMessage.js:19:33
at tryCatcher (/root/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/root/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/root/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/root/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/root/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/root/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/root/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/root/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)
{ UserID: 223426449,
UserName: 'INF_BOT',
RobuxBalance: 500,
TicketsBalance: 0,
ThumbnailUrl: 'http://t3.rbxcdn.com/ba696ca9354dc107b762e8bab75b69c7',
IsAnyBuildersClubMember: false }
1
Start: 1; End: 1
{ messages:
[ { sender: [Object],
subject: 'yeet',
body: 'sfsdf ',
created: 2017-06-20T00:58:00.000Z,
updated: 2017-06-20T08:33:00.000Z,
read: true,
parent: [Object],
id: 1931327446 } ],
totalPages: 1,
total: 1 }
Oh and here is the code I ran the above with;
var rbx = require('roblox-js');
function handle (err) {
console.error(err.stack);
}
rbx.login('INF_Bot','***')
.then(function () {
rbx.getCurrentUser().then(console.log);
rbx.getMessages().then(console.log);
var onMessage = rbx.onMessage();
onMessage.on('data', function (message) {
console.log(message);
});
onMessage.on('error', handle);
}).catch(handle);
@sentanos
It may have to do with not having enough messages in your inbox. Send a few more random ones, leave them there, and try again.
On Jun 20, 2017, at 12:36, ICostaEx notifications@github.com wrote:
Oh and here is the code I ran the above with;
var rbx = require('roblox-js');
function handle (err) { console.error(err.stack); }
rbx.login('INF_Bot','***') .then(function () { rbx.getCurrentUser().then(console.log); rbx.getMessages().then(console.log); var onMessage = rbx.onMessage(); onMessage.on('data', function (message) { console.log(message); }); onMessage.on('error', handle); }).catch(handle); @sentanos
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Added 12 messages to the bot account, still gives me the same error :/
Start: 0; End: 1
Unhandled rejection TypeError: Cannot read property 'id' of undefined
at /root/node_modules/roblox-js/lib/event/onMessage.js:19:33
at tryCatcher (/root/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/root/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/root/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/root/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/root/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/root/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/root/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/root/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)
{ UserID: 223426449,
UserName: 'INF_BOT',
RobuxBalance: 500,
TicketsBalance: 0,
ThumbnailUrl: 'http://t3.rbxcdn.com/ba696ca9354dc107b762e8bab75b69c7',
IsAnyBuildersClubMember: false }
1
Start: 1; End: 1
{ messages:
[ { sender: [Object],
subject: 'asdsdsdsad',
body: 'ddadsadsadsadsadsadsad',
created: 2017-06-20T23:50:00.000Z,
updated: 2017-06-20T23:50:00.000Z,
read: false,
parent: [Object],
id: 1935834009 },
{ sender: [Object],
subject: 'adfsdfasdf',
body: 'asdfasdfasdfasdfsadfasdfasdf',
created: 2017-06-20T23:49:00.000Z,
updated: 2017-06-20T23:49:00.000Z,
read: false,
parent: [Object],
id: 1935830933 },
{ sender: [Object],
subject: 'dlfjn',
body: 'ffaffdff',
created: 2017-06-20T23:49:00.000Z,
updated: 2017-06-20T23:49:00.000Z,
read: false,
parent: [Object],
id: 1935829642 },
{ sender: [Object],
subject: 'yeet',
body: 'sfsdf ',
created: 2017-06-20T00:58:00.000Z,
updated: 2017-06-20T08:33:00.000Z,
read: true,
parent: [Object],
id: 1931327446 },
{ sender: [Object],
subject: 'dasd',
body: 'adasd',
created: 2017-06-19T23:39:00.000Z,
updated: 2017-06-20T23:51:00.000Z,
read: true,
parent: [Object],
id: 1931002542 },
{ sender: [Object],
subject: 'af',
body: 'afasfs xcvfds as',
created: 2017-06-19T18:16:00.000Z,
updated: 2017-06-20T23:51:00.000Z,
read: true,
parent: [Object],
id: 1929655669 },
{ sender: [Object],
subject: 'adas',
body: 'asdas',
created: 2017-06-19T18:14:00.000Z,
updated: 2017-06-20T23:51:00.000Z,
read: true,
parent: [Object],
id: 1929647437 },
{ sender: [Object],
subject: 'Republic of Mali Invitation',
body: 'You're being invited to join the Republic of Mali, a communist nation in Central Africa which is currently being revived. We're in need of people to join the army, police, and government and would love to have you. If you're interested here's a link: https://www.roblox.com/My/Groups.aspx?gid=2684355',
created: 2017-03-02T05:21:00.000Z,
updated: 2017-06-20T23:51:00.000Z,
read: true,
parent: [Object],
id: 1585108118 },
{ sender: [Object],
subject: 'Russian Federation, over 16,000 members!',
body: 'Do you wish to join a large and active Russia with a dedicated government? Well, if so, the Russian Federation is for you! The Russian Federation has over 16,000 members! Growing fast too! We have an active capitol as well as a military base. You can become a part of the police, the army, an intelligence agency, and more! You can also run for government offices! We are currently looking for hard working, dedicated people who can be effective in the government, or even military! Just send the President a message! Why don't you come and just at least try us out? You will not regret it! Remember, you do not need to be Russian to join!',
created: 2017-03-01T15:08:00.000Z,
updated: 2017-06-20T23:51:00.000Z,
read: true,
parent: [Object],
id: 1583649353 },
{ sender: [Object],
subject: 'Donation',
body: 'I need 10 robux for itaf uniform 2/11/17',
created: 2017-02-11T19:48:00.000Z,
updated: 2017-06-20T23:51:00.000Z,
read: true,
parent: [Object],
id: 1541399321 },
{ sender: [Object],
subject: 'RE: ITA | Immigration Notice',
body: 'y'all hold too many grudges. ya boi already quit roblox, just trynna say hi<br /><br /><br />------------------------------<br />On 1/25/2017 at 5:50 PM, INF_BOT wrote:<br />Dear BatmanNX,<br /><br />You have been ranked at the rank "Federal Prison" due to your stance within the blacklist. If you would like to appeal this blacklist please message me or reply back to this message and it will be automatically forwarded to an immigration developer. <br /><br />- Italian Immigration Bot<br /> -Infius Integration',
created: 2017-01-27T21:50:00.000Z,
updated: 2017-06-20T23:51:00.000Z,
read: true,
parent: [Object],
id: 1506862477 },
{ sender: [Object],
subject: 'RE: Welcome to Italy!',
body: 'OH MY GOD<br /><br /><br />------------------------------<br />On 1/26/2017 at 11:46 PM, INF_BOT wrote:<br />Hello,<br />The developers of the Italian Republic would like to invite you to our new city, Rome!<br />▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬<br />This new and improved city will be released within the coming days, and when it is we would like to invite you to join us. The city includes a lot of improved things from when it was last around.<br />Such as;<br />- Improved cars,<br />- Improved Guns<br />- A new city layout<br />- New and improved UI<br />- and much more<br />▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬<br />When the city is launched you can join us here;<br />The City of Rome: https://www.roblox.com/games/580747431/City-of-Rome-Italy<br />▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬<br />Thank you,<br /> Italian Developers<br /><br /><br />- Powered by Infius Integration',
created: 2017-01-27T05:48:00.000Z,
updated: 2017-06-20T23:51:00.000Z,
read: true,
parent: [Object],
id: 1505684675 } ],
totalPages: 1,
total: 12 }
Even tried it on my main account with a total of 608 messages still got the same error.
It's coming from /root/node_modules/roblox-js/lib/event/onMessage.js:19:33
Line 19 is latest = initial.messages[0].id; - https://github.com/sentanos/roblox-js/blob/master/lib/event/onMessage.js
It does not seem to be an account issue, it seems to be an issue coming from the Lib itself. @sentanos
I will run my own tests whenever I get the chance. Unfortunately I'm very busy right now and haven't found the time to do it.
On Jun 20, 2017, at 16:02, ICostaEx notifications@github.com wrote:
Even tried it on my main account with a total of 608 messages still got the same error.
It's coming from /root/node_modules/roblox-js/lib/event/onMessage.js:19:33
Line 19 is latest = initial.messages[0].id; - https://github.com/sentanos/roblox-js/blob/master/lib/event/onMessage.js
It does not seem to be an account issue, it seems to be an issue coming from the Lib itself. @sentanos
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
I cannot reproduce the issue. Please contact me on discord or skype when you have the chance so I can coordinate this with you more easily. (Discord: Froast#5132; Skype: joshua.lanese)
When using events (such as onMessage) does the 'bot' need to be logged in like so: