I am writing a bot on JS using grammy bibliothek I made a function createStickerPack everything works but I need to make it so that when the user sends sticker pack names after creating a sticker the user's messages are deleted how to do it ?
I have a sample code how to do it but it doesn't work, maybe there are people who can help me.
bot.on('message', async (ctx) => {
// console.log(ctx.message)
if (ctx.message && ctx.message.text) {
const userId = ctx.message.from.id;
const sentMessage = await ctx.reply('Please wait...');
setTimeout(async () => {
try {
// Delete the user's message
await ctx.deleteMessage(sentMessage.chat.id, sentMessage.message_id);
await ctx.deleteMessage(ctx.message.chat.id, ctx.message.message_id); // Delete user message
} catch (error) {
console.error('Error while deleting message:', error);
}
}, 5000); // Delete message after 5 seconds 2(in the example)
}
});
bot.on('message', async (ctx) => {
// console.log(ctx.message)
if (ctx.message && ctx.message.text) {
const userId = ctx.message.from.id;
const sentMessage = await ctx.reply('Please wait...');
setTimeout(async () => {
try {
// Delete the user's message
await ctx.deleteMessage(sentMessage.chat.id, sentMessage.message_id);
await ctx.deleteMessage(ctx.message.chat.id, ctx.message.message_id); // Delete user message
} catch (error) {
console.error('Error while deleting message:', error);
}
}, 5000); // Delete message after 5 seconds 2(in the example)
}
});