gaber-elsayed

كود يشيل الخلفية عن الصور بامر remove ورابط الصورة لازم تحمل بكج remove.bg ,npm i remove.bg

Jul 14th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. const { RemoveBgResult, RemoveBgError, removeBackgroundFromImageUrl } = require("remove.bg");
  2. client.on('message', message =>{
  3. if(message.author.bot) return;
  4. if(!message.guild) return;
  5. if(message.content.startsWith(prefix + 'remove')){
  6. const url = message.content.split(' ').slice(1).join(' ')
  7. if(!url) return message.channel.send(`${prefix}remove <URL>`)
  8. const outputFile = `${__dirname}/${message.author.id}.png`;
  9.  
  10. try {
  11.  
  12.  
  13. removeBackgroundFromImageUrl({
  14. url,
  15. apiKey: "oEecsQFNG5NnzBVrVTUj6WxV",
  16. size: "regular",
  17. type: "auto",
  18. outputFile
  19. }).then(a=>{
  20. message.channel.send({files : [outputFile]})
  21. })
  22. } catch (error) {
  23. console.log(error)
  24. message.channel.send(error)
  25. }
  26. }
  27. })
  28. });
Advertisement
Add Comment
Please, Sign In to add comment