Skip to content

Instantly share code, notes, and snippets.

@Tarkiin
Last active August 1, 2024 14:02
Show Gist options
  • Save Tarkiin/71a2b9f06f4323544c1d17d99e179b6c to your computer and use it in GitHub Desktop.
Save Tarkiin/71a2b9f06f4323544c1d17d99e179b6c to your computer and use it in GitHub Desktop.
const { bot } = require('../lib');
bot(
{
pattern: 'ima',
fromMe: true,
desc: 'Send a specific image as media',
type: 'misc',
},
async (message, match) => {
// URL de la imagen a enviar
const imageUrl = 'https://cdn.pixabay.com/photo/2024/07/11/14/29/bee-8888442_1280.jpg';
try {
// Enviar un mensaje informativo
await message.send('Aquí está la imagen que solicitaste:');
// Verificar si el método sendFromUrl está disponible y funcional
if (typeof message.sendFromUrl === 'function') {
// Intentar enviar la imagen como media
await message.sendFromUrl(imageUrl);
} else {
throw new Error('Método sendFromUrl no disponible');
}
} catch (error) {
// Proporcionar detalles específicos del error
console.error('Error al enviar la imagen:', error);
await message.send('Error al enviar la imagen: ' + error.message);
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment