1.0.1 โข Published 10 months ago
crayon.ai v1.0.1
๐ Image generation ai
crayon.ai is an image generator ai based on 'Craiyon' formally known as Dall-E mini
๐ More information
- Craiyon already has its own npm package but it only works with api_key
- This package allows you to generate images without api_key
โ Installation
npm i crayon.ai
โจFeatures
- Easy to use
- discord.js support
- Works on anything
- Uses backend
- Returns buffer
- Doesnt work with NSFW prompts
Usage
Example usage:
const {generate} = require('crayon.ai')
const images = await generate('Ninja')
console.log(images[0]) // <Buffer>
Example discord bot:
// ... discord.js configuration ...
const {generate} = require('crayon.ai')
client.on('messageCreate', async (message) => {
if (message.content.startsWith('!ai')) {
const prompt = message.content.slice(4)
if (!prompt) return message.reply('Please give a prompt!')
try {
const images = await generate(prompt)
if (!image) return message.reply('Your prompt might be nsfw!')
message.channel.send(`Generating image...`)
const attachment = new Discord.AttachmentBuilder(images[0], { name: 'ai.png' })
message.channel.send({ content: `${message.author}, your image has been generated!`, files: [attachment]})
} catch(e) {
message.reply(`Oh no! an error occured because of **${e}**`)
}
}
})