mtproto-core
mtproto-core copied to clipboard
messages.sendMedia returns error because "call" is undefined
Describe the bug I can not execute sendMedia command, receiveing error message:
messages.sendMedia error: TypeError: Cannot read property 'call' of undefined
Code example
function sendMedia(mtprotoInstance, media, message, replyId) {
console.log("Broadcasting message with media");
console.log(mtprotoInstance)
let options = {
peer: {
_: "inputPeerChannel",
channel_id: process.env.BROADCAST_TEST_CHANNEL_ID,
access_hash: process.env.BROADCAST_TEST_CHANNEL_ACCESS_HASH,
},
message,
media,
random_id:
Math.ceil(Math.random() * 0xffffff) + Math.ceil(Math.random() * 0xffffff),
};
if (replyId) options.reply_to_msg_id = replyId;
return mtprotoInstance.call("messages.sendMedia", options);
}
mtproto instance is in a class here:
constructor(api_id, api_hash, dataFile) {
this.mtproto = new MTProto({
api_id,
api_hash,
invokeWithLayer: 0xda9b0d0d,
layer: 57,
initConnection: 0x69796de9,
app_version: "1.0.1",
lang_code: "es",
storageOptions: {
path: path.resolve(__dirname, `./data/${dataFile}.json`),
},
});
Expected behavior Media is sent.
Screenshots If applicable, add screenshots to help explain your problem.
Context:
- Library environment: node or browser: node
- Library version: 6.1.0
- Node version (if node environment): 14.18.1
- Browser version (if browser environment): x.x.x
Additional context Other methods like messages.sendMessage or messages.getAllChats, but this in particular returns that error and I can not figure out what is going on.