Plaintext avatar search
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
add a comment |
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
add a comment |
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
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
javascript node.js discord discord.js
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
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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);
}
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
add a comment |
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);
}
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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);
}
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
add a comment |
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);
}
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
add a comment |
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);
}
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);
}
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
add a comment |
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
add a comment |
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);
}
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
add a comment |
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);
}
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
add a comment |
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);
}
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);
}
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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