0
I’m doing a bot on Discord, and one of the functions I want on it is this: I want my bot when receiving an image sent by a user to edit it and return as a meme. From of course a specific command. In question of the editing itself I’ve done, I used npm jimp which edits images by js, any image inside my folder that I put as a variable will be edited and answered by the user, but I want the edited image to be one of the user’s choice, I have already read the documentation of Discordjs and I have not found any hint about this command, anyway in case you want me to be more specific just ask here, I think, here is my code.
module.exports = (client,msg)=>{ //exportando o client do meu bot e outros comandos
var jimp = require('jimp'); //npm que eu usei para editar as imagens por javascript
async function edicao(){
const bolsonaro = await jimp.read('bolsonaro2.jpeg')// imagem que vai servir de base para o meme
const image = await jimp.read('img.jpg')// imagem que vai ser editada
image.resize(308, 171)
image.rotate(-1);
bolsonaro.composite(image, 320,181).write('beta.png')
msg.reply(``, { files: ["beta.png"] })//resposta para o usuario que chamou pelo comando
console.log('Imagem enviada para o Discord')
.catch(err => {
console.log('error avatar')
})
}
return edicao();
}
Actually, it seems that attachments realize that it is an image, and this even printing the information of it, but he error when trying to edit the image, I think he did not take directly the image, only the ID, the name, the link... Any suggestions?
– Muriilo
@Muriilo just use the property
url
of the object in question in the functionjimp.read
– Sorack
guy like me would put it in code, I’m pretty beginner yet, sorry.
– Muriilo
@Muriilo does not know how to be clearer than in the previous comment. You have a part that reads the image and assigns the result to a variable (
await jimp.read
). Instead of passing the name of the image you will pass what is in the attributeurl
of the object contained in the collectionattachments
. So that I can help you more than that, at the very least you have to inform me the outcome of yourconsole.log
that I put in response– Sorack
@Muriilo I made an edit in my reply to try to give an example of how your code would look after modified, but as you did not provide an executable example I will hardly be able to help more than that.
– Sorack