Command avatar to bot in Discord.js

Asked

Viewed 1,156 times

1

I’m having trouble in command, I can give good avatar but it "ignores" users who use gif and turns it into jpg

const Discord = require('discord.js'); //puxo a api aqui pq deu um embed
module.exports = {
    name: 'avatar', //o nome pra puxar o comando
  aliases: ['foto', 'icon', 'pfp'],//nomes alternativos
  //Descrição dele
    description: 'Pegue a URL de avatar do user mencionado.', 
  //conando abaixo, após o execute()
  cooldown: 5,//tempo de espera pra executar novamente
      async execute (msg, args) {

if (!msg.mentions.users.size) {
   return msg.channel.send('Ninguém mencionado');
    //tirei pra ver o proprio avatar
    //caso queira colocar 
    //msg.channel.send(`seu avatar: ${msg.author.displayAvatarURL({ dynamic: true })}`);
}

const avatarList = msg.mentions.users.map(user => {
          let nicer = new Discord.MessageEmbed() //Criei o embed antes do return
        .setTitle(`${user.username}'s avatar`) 
        .setImage(`${user.displayAvatarURL({ size: 1024 })}`)
        .setColor("RANDOM")
         
         return msg.channel.send(nicer); //Retornei o embed
;

        });
        
        
        
}
};    

1 answer

0

const Discord = require("discord.js"); 

exports.run = async (client, message, args) => {

  let user = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author;
  
  let avatar = user.avatarURL({ dynamic: true, format: "png", size: 1024 });

  let embed = new Discord.MessageEmbed() 
    .setColor(`#00000`) 
    .setTitle(`Avatar de ${user.username}`) 
    .setImage(avatar) 
    .setFooter(`• Autor: ${message.author.tag}`, message.author.displayAvatarURL({format: "png"}));
 await message.channel.send(embed); 

};

If you want to change the bar color, press Ctrl + F to find setColor('#00000') and change the numbers.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.