alik0211 / mtproto-core

Telegram API JS (MTProto) client library for Node.js and browser
https://mtproto-core.js.org
GNU General Public License v3.0
633 stars 118 forks source link

Unable to get info about a channel #160

Open Ray-Garraty opened 3 years ago

Ray-Garraty commented 3 years ago

Hi! I'm starting to learn Telegram API, and need your advice. I want to get full info about channel using the api method 'channels.getFullChannel':

const params = {
    channel: {
      _: 'inputChannel',
      channel_id: -1001003399994,
      access_hash: 4872913646325428232,
    },
  };
  mtproto
    .call('channels.getFullChannel', params)
    .then(console.log)
    .catch((error) => {
      console.error(error.message);
      process.exit(1);
    });

For some mysterious reason it throws an error and exits. And I receive only 'undefined', not result or error message...

agsosa commented 3 years ago

The error object is something like this:

{ _: 'mt_rpc_error', error_code: 400, error_message: 'CHANNEL_INVALID' }

but you're using error.message instead of error.error_message that's the reason you're getting undefined.

the rest of the code is ok (make sure to pass a valid channel_id and access_hash)

alik0211 commented 3 years ago

Update the library to version 6 and try using the code from the documentation - https://mtproto-core.js.org/docs/call-the-telegram-methods#parse-all-messages-from-channel

danielehrhardt commented 2 years ago

Hi! I'm starting to learn Telegram API, and need your advice. I want to get full info about channel using the api method 'channels.getFullChannel':

const params = {
    channel: {
      _: 'inputChannel',
      channel_id: -1001003399994,
      access_hash: 4872913646325428232,
    },
  };
  mtproto
    .call('channels.getFullChannel', params)
    .then(console.log)
    .catch((error) => {
      console.error(error.message);
      process.exit(1);
    });

For some mysterious reason it throws an error and exits. And I receive only 'undefined', not result or error message...

i try to get the users from a channel but i am getting unkown error.