Plaintext avatar search












1















I have an avatar command that allows you to look up a member to get their avatar in Discord. The problem is that anytime I run the command with any arguments (implying you wanna find someone else's avatar, it sends a blank embed. It works fine sending the message author avatar, but not anyone else's.



exports.run = (client, message, args) => {
let mem = args.join(' ');
let memb = message.guild.members.find(m => [m.displayName.toLowerCase(), m.user.username.toLowerCase()].includes(mem.toLowerCase()));

let embed = new Discord.RichEmbed()
.setImage(memb ? memb.displayAvatarURL : message.author.displayAvatarURL)
.setColor(client.config.embedColor);

message.channel.send(embed);
}


Any help would be greatly appreciated, thank you.










share|improve this question





























    1















    I have an avatar command that allows you to look up a member to get their avatar in Discord. The problem is that anytime I run the command with any arguments (implying you wanna find someone else's avatar, it sends a blank embed. It works fine sending the message author avatar, but not anyone else's.



    exports.run = (client, message, args) => {
    let mem = args.join(' ');
    let memb = message.guild.members.find(m => [m.displayName.toLowerCase(), m.user.username.toLowerCase()].includes(mem.toLowerCase()));

    let embed = new Discord.RichEmbed()
    .setImage(memb ? memb.displayAvatarURL : message.author.displayAvatarURL)
    .setColor(client.config.embedColor);

    message.channel.send(embed);
    }


    Any help would be greatly appreciated, thank you.










    share|improve this question



























      1












      1








      1


      2






      I have an avatar command that allows you to look up a member to get their avatar in Discord. The problem is that anytime I run the command with any arguments (implying you wanna find someone else's avatar, it sends a blank embed. It works fine sending the message author avatar, but not anyone else's.



      exports.run = (client, message, args) => {
      let mem = args.join(' ');
      let memb = message.guild.members.find(m => [m.displayName.toLowerCase(), m.user.username.toLowerCase()].includes(mem.toLowerCase()));

      let embed = new Discord.RichEmbed()
      .setImage(memb ? memb.displayAvatarURL : message.author.displayAvatarURL)
      .setColor(client.config.embedColor);

      message.channel.send(embed);
      }


      Any help would be greatly appreciated, thank you.










      share|improve this question
















      I have an avatar command that allows you to look up a member to get their avatar in Discord. The problem is that anytime I run the command with any arguments (implying you wanna find someone else's avatar, it sends a blank embed. It works fine sending the message author avatar, but not anyone else's.



      exports.run = (client, message, args) => {
      let mem = args.join(' ');
      let memb = message.guild.members.find(m => [m.displayName.toLowerCase(), m.user.username.toLowerCase()].includes(mem.toLowerCase()));

      let embed = new Discord.RichEmbed()
      .setImage(memb ? memb.displayAvatarURL : message.author.displayAvatarURL)
      .setColor(client.config.embedColor);

      message.channel.send(embed);
      }


      Any help would be greatly appreciated, thank you.







      javascript node.js discord discord.js






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 17:35









      Federico Grandi

      2,81321127




      2,81321127










      asked Nov 20 '18 at 4:01









      Adam KerikAdam Kerik

      5318




      5318
























          2 Answers
          2






          active

          oldest

          votes


















          2














          It's not working because you're trying to use GuildMember.displayAvatarURL, but that is a User property: try using memb.user.displayAvatarURL:



          exports.run = (client, message, args) => {
          let mem = args.join(' ');
          let memb = message.guild.members.find(m => [m.displayName.toLowerCase(), m.user.username.toLowerCase()].includes(mem.toLowerCase()));

          let embed = new Discord.RichEmbed()
          .setImage(memb ? memb.user.displayAvatarURL : message.author.displayAvatarURL)
          .setColor(client.config.embedColor);

          message.channel.send(embed);
          }





          share|improve this answer
























          • Thank you so much! I really appreciate the answer as I was stumped. You, my friend, are a miracle worker.

            – Adam Kerik
            Nov 20 '18 at 17:48











          • Happy to hear that it worked :D

            – Federico Grandi
            Nov 20 '18 at 18:46



















          0














          Instead of making it so you type in the users' name, just make the command take a tagged user like so;



          exports.run = (client, message, args) => {
          if(!message.mentions.users.first()) return no.mention.function();
          let member = message.mentions.users.first();
          let memberAvatar = member.avatarURL;
          let embed = new Discord.RichEmbed()
          .setColor(client.config.embedColor)
          .setImage(memberAvatar);
          message.channel.send(embed);
          }





          share|improve this answer
























          • Thank you for your answer, but I specfically am avoiding that so I do not have to ping people.

            – Adam Kerik
            Nov 20 '18 at 17:47











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386028%2fplaintext-avatar-search%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          It's not working because you're trying to use GuildMember.displayAvatarURL, but that is a User property: try using memb.user.displayAvatarURL:



          exports.run = (client, message, args) => {
          let mem = args.join(' ');
          let memb = message.guild.members.find(m => [m.displayName.toLowerCase(), m.user.username.toLowerCase()].includes(mem.toLowerCase()));

          let embed = new Discord.RichEmbed()
          .setImage(memb ? memb.user.displayAvatarURL : message.author.displayAvatarURL)
          .setColor(client.config.embedColor);

          message.channel.send(embed);
          }





          share|improve this answer
























          • Thank you so much! I really appreciate the answer as I was stumped. You, my friend, are a miracle worker.

            – Adam Kerik
            Nov 20 '18 at 17:48











          • Happy to hear that it worked :D

            – Federico Grandi
            Nov 20 '18 at 18:46
















          2














          It's not working because you're trying to use GuildMember.displayAvatarURL, but that is a User property: try using memb.user.displayAvatarURL:



          exports.run = (client, message, args) => {
          let mem = args.join(' ');
          let memb = message.guild.members.find(m => [m.displayName.toLowerCase(), m.user.username.toLowerCase()].includes(mem.toLowerCase()));

          let embed = new Discord.RichEmbed()
          .setImage(memb ? memb.user.displayAvatarURL : message.author.displayAvatarURL)
          .setColor(client.config.embedColor);

          message.channel.send(embed);
          }





          share|improve this answer
























          • Thank you so much! I really appreciate the answer as I was stumped. You, my friend, are a miracle worker.

            – Adam Kerik
            Nov 20 '18 at 17:48











          • Happy to hear that it worked :D

            – Federico Grandi
            Nov 20 '18 at 18:46














          2












          2








          2







          It's not working because you're trying to use GuildMember.displayAvatarURL, but that is a User property: try using memb.user.displayAvatarURL:



          exports.run = (client, message, args) => {
          let mem = args.join(' ');
          let memb = message.guild.members.find(m => [m.displayName.toLowerCase(), m.user.username.toLowerCase()].includes(mem.toLowerCase()));

          let embed = new Discord.RichEmbed()
          .setImage(memb ? memb.user.displayAvatarURL : message.author.displayAvatarURL)
          .setColor(client.config.embedColor);

          message.channel.send(embed);
          }





          share|improve this answer













          It's not working because you're trying to use GuildMember.displayAvatarURL, but that is a User property: try using memb.user.displayAvatarURL:



          exports.run = (client, message, args) => {
          let mem = args.join(' ');
          let memb = message.guild.members.find(m => [m.displayName.toLowerCase(), m.user.username.toLowerCase()].includes(mem.toLowerCase()));

          let embed = new Discord.RichEmbed()
          .setImage(memb ? memb.user.displayAvatarURL : message.author.displayAvatarURL)
          .setColor(client.config.embedColor);

          message.channel.send(embed);
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 17:33









          Federico GrandiFederico Grandi

          2,81321127




          2,81321127













          • Thank you so much! I really appreciate the answer as I was stumped. You, my friend, are a miracle worker.

            – Adam Kerik
            Nov 20 '18 at 17:48











          • Happy to hear that it worked :D

            – Federico Grandi
            Nov 20 '18 at 18:46



















          • Thank you so much! I really appreciate the answer as I was stumped. You, my friend, are a miracle worker.

            – Adam Kerik
            Nov 20 '18 at 17:48











          • Happy to hear that it worked :D

            – Federico Grandi
            Nov 20 '18 at 18:46

















          Thank you so much! I really appreciate the answer as I was stumped. You, my friend, are a miracle worker.

          – Adam Kerik
          Nov 20 '18 at 17:48





          Thank you so much! I really appreciate the answer as I was stumped. You, my friend, are a miracle worker.

          – Adam Kerik
          Nov 20 '18 at 17:48













          Happy to hear that it worked :D

          – Federico Grandi
          Nov 20 '18 at 18:46





          Happy to hear that it worked :D

          – Federico Grandi
          Nov 20 '18 at 18:46













          0














          Instead of making it so you type in the users' name, just make the command take a tagged user like so;



          exports.run = (client, message, args) => {
          if(!message.mentions.users.first()) return no.mention.function();
          let member = message.mentions.users.first();
          let memberAvatar = member.avatarURL;
          let embed = new Discord.RichEmbed()
          .setColor(client.config.embedColor)
          .setImage(memberAvatar);
          message.channel.send(embed);
          }





          share|improve this answer
























          • Thank you for your answer, but I specfically am avoiding that so I do not have to ping people.

            – Adam Kerik
            Nov 20 '18 at 17:47
















          0














          Instead of making it so you type in the users' name, just make the command take a tagged user like so;



          exports.run = (client, message, args) => {
          if(!message.mentions.users.first()) return no.mention.function();
          let member = message.mentions.users.first();
          let memberAvatar = member.avatarURL;
          let embed = new Discord.RichEmbed()
          .setColor(client.config.embedColor)
          .setImage(memberAvatar);
          message.channel.send(embed);
          }





          share|improve this answer
























          • Thank you for your answer, but I specfically am avoiding that so I do not have to ping people.

            – Adam Kerik
            Nov 20 '18 at 17:47














          0












          0








          0







          Instead of making it so you type in the users' name, just make the command take a tagged user like so;



          exports.run = (client, message, args) => {
          if(!message.mentions.users.first()) return no.mention.function();
          let member = message.mentions.users.first();
          let memberAvatar = member.avatarURL;
          let embed = new Discord.RichEmbed()
          .setColor(client.config.embedColor)
          .setImage(memberAvatar);
          message.channel.send(embed);
          }





          share|improve this answer













          Instead of making it so you type in the users' name, just make the command take a tagged user like so;



          exports.run = (client, message, args) => {
          if(!message.mentions.users.first()) return no.mention.function();
          let member = message.mentions.users.first();
          let memberAvatar = member.avatarURL;
          let embed = new Discord.RichEmbed()
          .setColor(client.config.embedColor)
          .setImage(memberAvatar);
          message.channel.send(embed);
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 13:52









          ethamitcethamitc

          193111




          193111













          • Thank you for your answer, but I specfically am avoiding that so I do not have to ping people.

            – Adam Kerik
            Nov 20 '18 at 17:47



















          • Thank you for your answer, but I specfically am avoiding that so I do not have to ping people.

            – Adam Kerik
            Nov 20 '18 at 17:47

















          Thank you for your answer, but I specfically am avoiding that so I do not have to ping people.

          – Adam Kerik
          Nov 20 '18 at 17:47





          Thank you for your answer, but I specfically am avoiding that so I do not have to ping people.

          – Adam Kerik
          Nov 20 '18 at 17:47


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386028%2fplaintext-avatar-search%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          Npm cannot find a required file even through it is in the searched directory