Closed ahmed-safari closed 2 years ago
odd, thanks for filling template.
I guess with MD we should keep the mindset of anything that can go wrong will go wrong
is this still happening?
yes
@Sp0derDev I literally copy pasted your exact code and cannot replicate this odd behaviour where the promise both resolves and throws an error - which seems like an impossible situation as is.
I suggest trying to isolate the behaviour by using just this code and see if it happens again.
This is literally all I'm trying:
const start = async () => {
try {
const client = await create({
headless: false,
sessionId: "md_test",
multiDevice: true,
disableSpins: true,
qrTimeout: 0,
logConsole: true,
logConsoleErrors: true,
authTimeout: 0,
licenseKey: "..."
});
client.onMessage(async m => {
try {
if (m.from === 'MY_NUMBER') {
let mediaData;
if (m.type === 'sticker') {
const stickerDecryptable = await client.getStickerDecryptable(m.id);
if (stickerDecryptable) mediaData = await decryptMedia(stickerDecryptable);
} else {
mediaData = await decryptMedia(m);
}
if (mediaData) {
client.sendImageAsSticker(m.from, `data:${m.mimetype};base64,${mediaData.toString('base64')}`, {
author: 'Ahmeds Bot',
pack: 'Insta: @Download.Media',
keepScale: true,
discord: '295155004996714497'
})
.then(() => {
console.log('SUCCESS', `Sticker Sent!`)
}).catch(err => {
client.reply(m.from, `Oh No 😰\nAn Error Occured While Proccessing The Sticker.\nPlease Try Again In A Few Seconds..\n\nError: ${err.name}`, m.id)
console.error('FAIL', err);
})
}
}
} catch (error) {
console.log("🚀 start ~ error", error)
}
})
} catch (error) {
console.error(error)
}
}
start();
Something else must be going on here. Till you can provide some reproducible code I will have to close this issue thanks.
Are you using the latest version of the library?
Current Behavior
`The
sendImageAsSticker` method throws an error even after successfully sending the sticker.The error is:
Expected Behavior
It should send the sticker and move to the "then" block instead of the "catch" block.
Steps To Reproduce
after running this command, the bot successfully sends the sticker but ends up sending an error message to the user as well as log the error mentioned above.
Mode
My own code
create() code
DEBUG INFO
Environment
Screenshots
No response
Anything else?
No response