Comparing version 0.1.2-aplha to 1.0.0
@@ -1,9 +0,5 @@ | ||
const Card = require("./src/Card"); | ||
const Bienvenida = require("./src/Bienvenida"); | ||
const Img = require("./src/Img"); | ||
module.exports = { | ||
Card, | ||
Bienvenida, | ||
Img | ||
}; |
{ | ||
"name": "spoondev", | ||
"version": "0.1.2-aplha", | ||
"version": "1.0.0", | ||
"description": "Modulo npm para manipular imagenes", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,43 +0,40 @@ | ||
# Bienvenidos a Spoon (Version Alpha) | ||
# Bienvenidos a Spoon | ||
Este modulo te servira para manipular imagenes, como por ejemplo arregar imagenes, texto y cambiar el color de los textos. | ||
Este Modulo npm esta pensado para realizar tu bot de Discord. | ||
#Ejemplo | ||
## Modo de uso | ||
``` | ||
const { Card, Bienvenida, Img } = require("tu-modulo"); | ||
const Spoon = require("spoondev"); | ||
const token = "aqui-va-tu-token" | ||
const token = "AQUÍ_EL_TOKEN_DE_AUTENTICACIÓN"; | ||
const config = { | ||
text: "Titulo", | ||
text2: "descripcion", | ||
image_user: "https://www.kindpng.com/picc/m/394-3947019_round-profile-picture-png-transparent-png.png", | ||
background_image: "https://cdn.pixabay.com/photo/2015/10/29/14/38/web-1012467_1280.jpg", | ||
colorTxt: "white", | ||
colorTxt2: "red", | ||
}; | ||
const bienvenida = new Bienvenida(config); | ||
const card = new Card(token); | ||
const img = new Img(token); | ||
bienvenida | ||
const img = new Spoon.Img(token) | ||
const bienvenida = new img.card.bienvenida() | ||
.token(token) | ||
.titulo("Título de bienvenida") | ||
.colorTit("blue") | ||
.descripcion("Descripción de bienvenida") | ||
.colorDesc("green") | ||
.avatar("https://www.example.com/avatar.png") | ||
.fondo("https://www.example.com/background.png"); | ||
.titulo('Juanppdev') | ||
.colorTit('white') | ||
.colorDesc('black') | ||
.descripcion('Bienvenid@ al servidor') | ||
.avatar(interaction.user.avatarURL({extension: "png"})) | ||
.fondo('https://i.imgur.com/BdosPHw.png'); | ||
await wait(4000) | ||
const buffer = await img.card.render(bienvenida); | ||
if (Buffer.isBuffer(buffer)) { | ||
const attachment = new AttachmentBuilder(buffer, { name: 'default.png' }); | ||
await interaction.editReply({ | ||
files: [attachment], | ||
}); | ||
} else { | ||
console.error('Error: El recurso generado no es un buffer válido.'); | ||
} | ||
``` | ||
card | ||
.render(bienvenida) | ||
.then(data => { | ||
console.log("Imagen generada:", data); | ||
}) | ||
.catch(error => { | ||
console.error("Error al generar la imagen:", error); | ||
}); | ||
``` | ||
# Versiones | ||
| Version | Descripcion | | ||
|-----------------------| | ||
| 1.0.0 | generacion de imagenes arreglada | |
@@ -0,45 +1,77 @@ | ||
const fetch = require("node-fetch"); | ||
class Bienvenida { | ||
constructor(datos = {}) { | ||
let keys = Object.keys(datos); | ||
if (keys.length > 0) { | ||
for (var i in keys) this[keys[i]] = datos[keys[i]]; | ||
constructor(datos = {}) { | ||
let keys = Object.keys(datos) | ||
if (keys.length > 0) { | ||
for (var i in keys) this[keys[i]] = datos[keys[i]] | ||
} | ||
} | ||
} | ||
async generarImagen() { | ||
const apiUrl = 'https://spoonapi-1-d2591244.deta.app/generate_image'; | ||
const queryParams = new URLSearchParams({ | ||
text: this.tit, | ||
text2: this.desc, | ||
image_user: this.avatar, | ||
colorTxt: this.colortit, | ||
colorTxt2: this.colordesc, | ||
background_image: this.fondo, | ||
}); | ||
const urlWithParams = `${apiUrl}?${queryParams}`; | ||
const requestOptions = { | ||
method: 'GET', | ||
headers: { | ||
Authorization: `Bearer ${this.token}`, | ||
}, | ||
}; | ||
try { | ||
const response = await fetch(urlWithParams, requestOptions); | ||
const buffer = await response.buffer(); | ||
return buffer; | ||
} catch (error) { | ||
console.error('Error:', error); | ||
throw error; | ||
} | ||
} | ||
token(token) { | ||
this.token = token; | ||
return this; | ||
} | ||
token(token) { | ||
this.token = token | ||
return this; | ||
} | ||
titulo(tit) { | ||
this.tit = tit; | ||
return this; | ||
} | ||
colorTit(ctit) { | ||
this.colortit = ctit | ||
return this | ||
} | ||
colorDesc(cdesc) { | ||
this.colordesc = cdesc | ||
titulo(tit) { | ||
this.tit = tit; | ||
return this; | ||
} | ||
return this; | ||
} | ||
descripcion(desc) { | ||
this.desc = desc | ||
colorTit(ctit) { | ||
this.colortit = ctit; | ||
return this; | ||
} | ||
return this; | ||
} | ||
avatar(avatar) { | ||
this.avatar = avatar; | ||
return this; | ||
} | ||
fondo(fondo) { | ||
this.fondo = fondo; | ||
return this; | ||
} | ||
} | ||
colorDesc(cdesc) { | ||
this.colordesc = cdesc; | ||
return this; | ||
} | ||
descripcion(desc) { | ||
this.desc = desc; | ||
return this; | ||
} | ||
avatar(avatar) { | ||
this.avatar = avatar; | ||
return this; | ||
} | ||
fondo(fondo) { | ||
this.fondo = fondo; | ||
return this; | ||
} | ||
} | ||
module.exports = Bienvenida; | ||
module.exports = Bienvenida; |
const request = require("node-superfetch"); | ||
const Bienvenida = require('./Bienvenida'); | ||
@@ -8,19 +7,16 @@ class Card { | ||
this.token = token; | ||
this.bienvenida = new Bienvenida(); | ||
this.bienvenida = require("./Bienvenida"); | ||
} | ||
async render(render) { | ||
try { | ||
const { body } = await request | ||
.post("https://spoonapi-1-n5834322.deta.app/generate_image") | ||
.set("Authorization", this.token) | ||
.send(render); | ||
return body; | ||
} catch (error) { | ||
throw new Error("Error al generar la imagen: " + error.message); | ||
} | ||
try { | ||
const buffer = await render.generarImagen(); | ||
return buffer; | ||
} catch (error) { | ||
console.log(`Spoon.API-Error: ${error.message}`); | ||
} | ||
} | ||
module.exports = Card; | ||
} | ||
module.exports = Card; |
const Card = require("./Card"); | ||
const Bienvenida = require("./Bienvenida"); | ||
@@ -7,3 +8,4 @@ class Img { | ||
this.token = token; | ||
this.card = new Card(token); | ||
this.card = new Card(this.token); | ||
this.bienvenida = new Bienvenida(); | ||
} | ||
@@ -10,0 +12,0 @@ } |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3905
94
1
40
1