Bug: Cannot return invalid text for questions #27

Closed
opened 2016-10-27 21:52:33 +00:00 by austinhuang0131 · 1 comment
austinhuang0131 commented 2016-10-27 21:52:33 +00:00 (Migrated from github.com)

The input is:

bot.command('mcserver [ip]', function(message) {
    if (message.args.ip !== undefined) {
/* Ignore this part, it works correctly */
    }
    else {
        const q = new Question()
                      .text('Type in the address, or click the Cancel button.')
                      .answers([['Cancel']])
                      .to(message.chat.id);
        bot.send(q).then(message => {
          console.log('Valid Answer:', message.text);
        }, msg => {
          console.log('Invalid:', msg.text);
        });
    }
});

The output is:

{ message_id: 163,
  from: 
   { id: 265228448,
     first_name: 'Austin',
     last_name: 'Huang',
     username: 'austinhuang' },
  chat: 
   { id: 265228448,
     first_name: 'Austin',
     last_name: 'Huang',
     username: 'austinhuang',
     type: 'private' },
  date: 1477604906,
  text: 'test' }
(node:27815) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'text' of undefined
(node:27815) 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.

#20

The input is: ``` js bot.command('mcserver [ip]', function(message) { if (message.args.ip !== undefined) { /* Ignore this part, it works correctly */ } else { const q = new Question() .text('Type in the address, or click the Cancel button.') .answers([['Cancel']]) .to(message.chat.id); bot.send(q).then(message => { console.log('Valid Answer:', message.text); }, msg => { console.log('Invalid:', msg.text); }); } }); ``` The output is: ``` { message_id: 163, from: { id: 265228448, first_name: 'Austin', last_name: 'Huang', username: 'austinhuang' }, chat: { id: 265228448, first_name: 'Austin', last_name: 'Huang', username: 'austinhuang', type: 'private' }, date: 1477604906, text: 'test' } (node:27815) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'text' of undefined (node:27815) 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. ``` #20
austinhuang0131 commented 2016-10-27 21:55:22 +00:00 (Migrated from github.com)

Oh it's the same question

Oh it's the same question
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: thereadme/node-telegram-api#27
No description provided.