Skip to content

Instantly share code, notes, and snippets.

@Tarkiin
Created August 1, 2024 15:57
Show Gist options
  • Save Tarkiin/75303034192686931535f50827cd6ab3 to your computer and use it in GitHub Desktop.
Save Tarkiin/75303034192686931535f50827cd6ab3 to your computer and use it in GitHub Desktop.
const { bot } = require('../lib/');
const path = require('path');
const fs = require('fs');
// Directorio de imágenes
const imageDirectory = path.join(__dirname, 'images');
// Nombre del archivo de imagen
const imageFileName = 'acolores.jpg';
bot(
{
pattern: 'ima',
fromMe: true,
desc: 'Sends the acolores image from the images directory',
type: 'misc',
},
async (message, match) => {
// Construir la ruta del archivo de imagen
const imagePath = path.join(imageDirectory, imageFileName);
// Verificar si el archivo de imagen existe
if (fs.existsSync(imagePath)) {
// Enviar la imagen desde el archivo
await message.send({ file: imagePath, mimetype: 'image/jpeg' });
} else {
// Enviar un mensaje de error si la imagen no existe
await message.send('Imagen no encontrada.');
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment