Getting an image URL from a messageRemove empty elements from an array in JavascriptHow do I get started with Node.jsHow do I get the path to the current script with Node.js?In Node.js, how do I “include” functions from my other files?How to get GET (query string) variables in Express.js on Node.js?How to get the full url in Express?How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)Discord.js Trying to send embed, but just sends empty messageGetting the URL from a submitted imageGet the Emoji url from a message in discord.js

Designing a time thief proof safe

Hiking with a mule or two?

Averting Bathos

How can this Stack Exchange site have an animated favicon?

Are lawyers allowed to come to agreements with opposing lawyers without the client's knowledge or consent?

Is it acceptable to say that a reviewer's concern is not going to be addressed because then the paper would be too long?

How can I repair this gas leak on my new range? Teflon tape isn't working

What exactly did this mechanic sabotage on the American Airlines 737, and how dangerous was it?

My manager quit. Should I agree to defer wage increase to accommodate budget concerns?

How to say "cheat sheet" in French

Is it impolite to ask for halal food when traveling to and in Thailand?

Why did the Soviet Union not "grant" Inner Mongolia to Mongolia after World War Two?

Do I have advantage with Riposte when moving away from a flanked enemy and triggering an opportunity attack?

Should the average user with no special access rights be worried about SMS-based 2FA being theoretically interceptable?

Proper way to shut down consumer

Do we know the situation in Britain before Sealion (summer 1940)?

Co-supervisor comes to the office to help her students, which distracts me

Suffocation while cooking under an umbrella?

What are the consequences of high orphan block rate?

Can the U.S. president make military decisions without consulting anyone?

2000s Animated TV show where teenagers could physically go into a virtual world

Going to France with limited French for a day

Safe to use 220V electric clothes dryer when building has been bridged down to 110V?

Why does C++ have 'Undefined Behaviour' and other languages like C# or Java don't?



Getting an image URL from a message


Remove empty elements from an array in JavascriptHow do I get started with Node.jsHow do I get the path to the current script with Node.js?In Node.js, how do I “include” functions from my other files?How to get GET (query string) variables in Express.js on Node.js?How to get the full url in Express?How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)Discord.js Trying to send embed, but just sends empty messageGetting the URL from a submitted imageGet the Emoji url from a message in discord.js






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I want to get the image URL or the image itself from a message, and put it in my embed. I have no idea to do it myself, hope you can help me :)



client.on('messageReactionAdd', (reaction, user, message) => 
const eggsa = client.emojis.find(emoji => emoji.name === "eggsa");
if (reaction.emoji.name === 'eggsa')
const msg = reaction.message;
const guild = msg.guild;
const guildMembers = guild.members;
const guildMember = guildMembers.get(user.id);
if (!guildMember.roles.some(r=>["Leder"].includes(r.name)) ) return guildMember.send(" ',:^\ ");
const message = reaction.message;
const kanal = reaction.message.guild.channels.find('name', 'sitater');
var embed = new Discord.RichEmbed()
.setDescription(message.content)
.setTimestamp()
.setFooter(message.author.username, reaction.message.author.avatarURL)
.setImage()
kanal.send(embed);

);









share|improve this question


























  • Welcome to Stackoverflow! Could you give us some more details please. Is it a normal text message in a guild textchannel or is it a RichEmbed? Is the message only a url with an image or is there also other text in and you want to find where the url is? ... Answers on this questions would help us to help you! :)

    – Gilles Heinesch
    Mar 30 at 8:04











  • Its a normal text message in a guild textchannel, and there would be text and an image attached to the message. The image would be normally just uploaded directly to discord so there would be no direct link. I want it to recreate the message as a richEmbed, so it would have a quote feel. Hope this helps and ty :) imgur.com/IMXDv9Y i want it to look something like this

    – blydex
    Mar 30 at 8:13


















1















I want to get the image URL or the image itself from a message, and put it in my embed. I have no idea to do it myself, hope you can help me :)



client.on('messageReactionAdd', (reaction, user, message) => 
const eggsa = client.emojis.find(emoji => emoji.name === "eggsa");
if (reaction.emoji.name === 'eggsa')
const msg = reaction.message;
const guild = msg.guild;
const guildMembers = guild.members;
const guildMember = guildMembers.get(user.id);
if (!guildMember.roles.some(r=>["Leder"].includes(r.name)) ) return guildMember.send(" ',:^\ ");
const message = reaction.message;
const kanal = reaction.message.guild.channels.find('name', 'sitater');
var embed = new Discord.RichEmbed()
.setDescription(message.content)
.setTimestamp()
.setFooter(message.author.username, reaction.message.author.avatarURL)
.setImage()
kanal.send(embed);

);









share|improve this question


























  • Welcome to Stackoverflow! Could you give us some more details please. Is it a normal text message in a guild textchannel or is it a RichEmbed? Is the message only a url with an image or is there also other text in and you want to find where the url is? ... Answers on this questions would help us to help you! :)

    – Gilles Heinesch
    Mar 30 at 8:04











  • Its a normal text message in a guild textchannel, and there would be text and an image attached to the message. The image would be normally just uploaded directly to discord so there would be no direct link. I want it to recreate the message as a richEmbed, so it would have a quote feel. Hope this helps and ty :) imgur.com/IMXDv9Y i want it to look something like this

    – blydex
    Mar 30 at 8:13














1












1








1








I want to get the image URL or the image itself from a message, and put it in my embed. I have no idea to do it myself, hope you can help me :)



client.on('messageReactionAdd', (reaction, user, message) => 
const eggsa = client.emojis.find(emoji => emoji.name === "eggsa");
if (reaction.emoji.name === 'eggsa')
const msg = reaction.message;
const guild = msg.guild;
const guildMembers = guild.members;
const guildMember = guildMembers.get(user.id);
if (!guildMember.roles.some(r=>["Leder"].includes(r.name)) ) return guildMember.send(" ',:^\ ");
const message = reaction.message;
const kanal = reaction.message.guild.channels.find('name', 'sitater');
var embed = new Discord.RichEmbed()
.setDescription(message.content)
.setTimestamp()
.setFooter(message.author.username, reaction.message.author.avatarURL)
.setImage()
kanal.send(embed);

);









share|improve this question
















I want to get the image URL or the image itself from a message, and put it in my embed. I have no idea to do it myself, hope you can help me :)



client.on('messageReactionAdd', (reaction, user, message) => 
const eggsa = client.emojis.find(emoji => emoji.name === "eggsa");
if (reaction.emoji.name === 'eggsa')
const msg = reaction.message;
const guild = msg.guild;
const guildMembers = guild.members;
const guildMember = guildMembers.get(user.id);
if (!guildMember.roles.some(r=>["Leder"].includes(r.name)) ) return guildMember.send(" ',:^\ ");
const message = reaction.message;
const kanal = reaction.message.guild.channels.find('name', 'sitater');
var embed = new Discord.RichEmbed()
.setDescription(message.content)
.setTimestamp()
.setFooter(message.author.username, reaction.message.author.avatarURL)
.setImage()
kanal.send(embed);

);






node.js discord discord.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 17:47









bahman parsamanesh

1,6631 gold badge6 silver badges22 bronze badges




1,6631 gold badge6 silver badges22 bronze badges










asked Mar 28 at 17:41









blydexblydex

85 bronze badges




85 bronze badges















  • Welcome to Stackoverflow! Could you give us some more details please. Is it a normal text message in a guild textchannel or is it a RichEmbed? Is the message only a url with an image or is there also other text in and you want to find where the url is? ... Answers on this questions would help us to help you! :)

    – Gilles Heinesch
    Mar 30 at 8:04











  • Its a normal text message in a guild textchannel, and there would be text and an image attached to the message. The image would be normally just uploaded directly to discord so there would be no direct link. I want it to recreate the message as a richEmbed, so it would have a quote feel. Hope this helps and ty :) imgur.com/IMXDv9Y i want it to look something like this

    – blydex
    Mar 30 at 8:13


















  • Welcome to Stackoverflow! Could you give us some more details please. Is it a normal text message in a guild textchannel or is it a RichEmbed? Is the message only a url with an image or is there also other text in and you want to find where the url is? ... Answers on this questions would help us to help you! :)

    – Gilles Heinesch
    Mar 30 at 8:04











  • Its a normal text message in a guild textchannel, and there would be text and an image attached to the message. The image would be normally just uploaded directly to discord so there would be no direct link. I want it to recreate the message as a richEmbed, so it would have a quote feel. Hope this helps and ty :) imgur.com/IMXDv9Y i want it to look something like this

    – blydex
    Mar 30 at 8:13

















Welcome to Stackoverflow! Could you give us some more details please. Is it a normal text message in a guild textchannel or is it a RichEmbed? Is the message only a url with an image or is there also other text in and you want to find where the url is? ... Answers on this questions would help us to help you! :)

– Gilles Heinesch
Mar 30 at 8:04





Welcome to Stackoverflow! Could you give us some more details please. Is it a normal text message in a guild textchannel or is it a RichEmbed? Is the message only a url with an image or is there also other text in and you want to find where the url is? ... Answers on this questions would help us to help you! :)

– Gilles Heinesch
Mar 30 at 8:04













Its a normal text message in a guild textchannel, and there would be text and an image attached to the message. The image would be normally just uploaded directly to discord so there would be no direct link. I want it to recreate the message as a richEmbed, so it would have a quote feel. Hope this helps and ty :) imgur.com/IMXDv9Y i want it to look something like this

– blydex
Mar 30 at 8:13






Its a normal text message in a guild textchannel, and there would be text and an image attached to the message. The image would be normally just uploaded directly to discord so there would be no direct link. I want it to recreate the message as a richEmbed, so it would have a quote feel. Hope this helps and ty :) imgur.com/IMXDv9Y i want it to look something like this

– blydex
Mar 30 at 8:13













1 Answer
1






active

oldest

votes


















0
















You can simply use the .attachments property from the message object. This returns you all attachments of this message included all pictures. From there on, you can use the property .url and this gives you the image url that you can add in your embed.



In the following code I added a check if there are even attachments. If yes, add the first image url as image of the embed.



Here is the code:



 client.on('messageReactionAdd', (reaction, user, message) => 
const eggsa = client.emojis.find(emoji => emoji.name === 'eggsa');
if (reaction.emoji.name === 'eggsa')
const msg = reaction.message;
const guild = msg.guild;
const guildMembers = guild.members;
const guildMember = guildMembers.get(user.id);
if (!guildMember.roles.some(r => ['Leder'].includes(r.name))) return guildMember.send(" ',:^\ ");
const message = reaction.message;
const kanal = reaction.message.guild.channels.find('name', 'sitater');
const embed = new Discord.RichEmbed()
.setDescription(message.content)
.setTimestamp()
.setFooter(message.author.username, reaction.message.author.avatarURL);

if (message.attachments.size !== 0)
embed.setImage(message.attachments.first().url);


kanal.send( embed );

);





share|improve this answer



























  • It crashes when i add the emoji to a message and can you help me show the erros

    – blydex
    Mar 30 at 8:30












  • Does the emoji event exist? Try to remove this line of this emoji because that's another question. Try to test the code with the message.attachments please @blydex

    – Gilles Heinesch
    Mar 30 at 8:31











  • err: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'url' of undefined

    – blydex
    Mar 30 at 8:50












  • I fixed an issue in my code. Can you try it again please @blydex

    – Gilles Heinesch
    Mar 30 at 8:55






  • 1





    it works now, tysm :)

    – blydex
    Mar 30 at 9:03













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/4.0/"u003ecc by-sa 4.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%2f55403855%2fgetting-an-image-url-from-a-message%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0
















You can simply use the .attachments property from the message object. This returns you all attachments of this message included all pictures. From there on, you can use the property .url and this gives you the image url that you can add in your embed.



In the following code I added a check if there are even attachments. If yes, add the first image url as image of the embed.



Here is the code:



 client.on('messageReactionAdd', (reaction, user, message) => 
const eggsa = client.emojis.find(emoji => emoji.name === 'eggsa');
if (reaction.emoji.name === 'eggsa')
const msg = reaction.message;
const guild = msg.guild;
const guildMembers = guild.members;
const guildMember = guildMembers.get(user.id);
if (!guildMember.roles.some(r => ['Leder'].includes(r.name))) return guildMember.send(" ',:^\ ");
const message = reaction.message;
const kanal = reaction.message.guild.channels.find('name', 'sitater');
const embed = new Discord.RichEmbed()
.setDescription(message.content)
.setTimestamp()
.setFooter(message.author.username, reaction.message.author.avatarURL);

if (message.attachments.size !== 0)
embed.setImage(message.attachments.first().url);


kanal.send( embed );

);





share|improve this answer



























  • It crashes when i add the emoji to a message and can you help me show the erros

    – blydex
    Mar 30 at 8:30












  • Does the emoji event exist? Try to remove this line of this emoji because that's another question. Try to test the code with the message.attachments please @blydex

    – Gilles Heinesch
    Mar 30 at 8:31











  • err: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'url' of undefined

    – blydex
    Mar 30 at 8:50












  • I fixed an issue in my code. Can you try it again please @blydex

    – Gilles Heinesch
    Mar 30 at 8:55






  • 1





    it works now, tysm :)

    – blydex
    Mar 30 at 9:03















0
















You can simply use the .attachments property from the message object. This returns you all attachments of this message included all pictures. From there on, you can use the property .url and this gives you the image url that you can add in your embed.



In the following code I added a check if there are even attachments. If yes, add the first image url as image of the embed.



Here is the code:



 client.on('messageReactionAdd', (reaction, user, message) => 
const eggsa = client.emojis.find(emoji => emoji.name === 'eggsa');
if (reaction.emoji.name === 'eggsa')
const msg = reaction.message;
const guild = msg.guild;
const guildMembers = guild.members;
const guildMember = guildMembers.get(user.id);
if (!guildMember.roles.some(r => ['Leder'].includes(r.name))) return guildMember.send(" ',:^\ ");
const message = reaction.message;
const kanal = reaction.message.guild.channels.find('name', 'sitater');
const embed = new Discord.RichEmbed()
.setDescription(message.content)
.setTimestamp()
.setFooter(message.author.username, reaction.message.author.avatarURL);

if (message.attachments.size !== 0)
embed.setImage(message.attachments.first().url);


kanal.send( embed );

);





share|improve this answer



























  • It crashes when i add the emoji to a message and can you help me show the erros

    – blydex
    Mar 30 at 8:30












  • Does the emoji event exist? Try to remove this line of this emoji because that's another question. Try to test the code with the message.attachments please @blydex

    – Gilles Heinesch
    Mar 30 at 8:31











  • err: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'url' of undefined

    – blydex
    Mar 30 at 8:50












  • I fixed an issue in my code. Can you try it again please @blydex

    – Gilles Heinesch
    Mar 30 at 8:55






  • 1





    it works now, tysm :)

    – blydex
    Mar 30 at 9:03













0














0










0









You can simply use the .attachments property from the message object. This returns you all attachments of this message included all pictures. From there on, you can use the property .url and this gives you the image url that you can add in your embed.



In the following code I added a check if there are even attachments. If yes, add the first image url as image of the embed.



Here is the code:



 client.on('messageReactionAdd', (reaction, user, message) => 
const eggsa = client.emojis.find(emoji => emoji.name === 'eggsa');
if (reaction.emoji.name === 'eggsa')
const msg = reaction.message;
const guild = msg.guild;
const guildMembers = guild.members;
const guildMember = guildMembers.get(user.id);
if (!guildMember.roles.some(r => ['Leder'].includes(r.name))) return guildMember.send(" ',:^\ ");
const message = reaction.message;
const kanal = reaction.message.guild.channels.find('name', 'sitater');
const embed = new Discord.RichEmbed()
.setDescription(message.content)
.setTimestamp()
.setFooter(message.author.username, reaction.message.author.avatarURL);

if (message.attachments.size !== 0)
embed.setImage(message.attachments.first().url);


kanal.send( embed );

);





share|improve this answer















You can simply use the .attachments property from the message object. This returns you all attachments of this message included all pictures. From there on, you can use the property .url and this gives you the image url that you can add in your embed.



In the following code I added a check if there are even attachments. If yes, add the first image url as image of the embed.



Here is the code:



 client.on('messageReactionAdd', (reaction, user, message) => 
const eggsa = client.emojis.find(emoji => emoji.name === 'eggsa');
if (reaction.emoji.name === 'eggsa')
const msg = reaction.message;
const guild = msg.guild;
const guildMembers = guild.members;
const guildMember = guildMembers.get(user.id);
if (!guildMember.roles.some(r => ['Leder'].includes(r.name))) return guildMember.send(" ',:^\ ");
const message = reaction.message;
const kanal = reaction.message.guild.channels.find('name', 'sitater');
const embed = new Discord.RichEmbed()
.setDescription(message.content)
.setTimestamp()
.setFooter(message.author.username, reaction.message.author.avatarURL);

if (message.attachments.size !== 0)
embed.setImage(message.attachments.first().url);


kanal.send( embed );

);






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 30 at 9:01

























answered Mar 30 at 8:20









Gilles HeineschGilles Heinesch

1,4711 gold badge11 silver badges26 bronze badges




1,4711 gold badge11 silver badges26 bronze badges















  • It crashes when i add the emoji to a message and can you help me show the erros

    – blydex
    Mar 30 at 8:30












  • Does the emoji event exist? Try to remove this line of this emoji because that's another question. Try to test the code with the message.attachments please @blydex

    – Gilles Heinesch
    Mar 30 at 8:31











  • err: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'url' of undefined

    – blydex
    Mar 30 at 8:50












  • I fixed an issue in my code. Can you try it again please @blydex

    – Gilles Heinesch
    Mar 30 at 8:55






  • 1





    it works now, tysm :)

    – blydex
    Mar 30 at 9:03

















  • It crashes when i add the emoji to a message and can you help me show the erros

    – blydex
    Mar 30 at 8:30












  • Does the emoji event exist? Try to remove this line of this emoji because that's another question. Try to test the code with the message.attachments please @blydex

    – Gilles Heinesch
    Mar 30 at 8:31











  • err: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'url' of undefined

    – blydex
    Mar 30 at 8:50












  • I fixed an issue in my code. Can you try it again please @blydex

    – Gilles Heinesch
    Mar 30 at 8:55






  • 1





    it works now, tysm :)

    – blydex
    Mar 30 at 9:03
















It crashes when i add the emoji to a message and can you help me show the erros

– blydex
Mar 30 at 8:30






It crashes when i add the emoji to a message and can you help me show the erros

– blydex
Mar 30 at 8:30














Does the emoji event exist? Try to remove this line of this emoji because that's another question. Try to test the code with the message.attachments please @blydex

– Gilles Heinesch
Mar 30 at 8:31





Does the emoji event exist? Try to remove this line of this emoji because that's another question. Try to test the code with the message.attachments please @blydex

– Gilles Heinesch
Mar 30 at 8:31













err: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'url' of undefined

– blydex
Mar 30 at 8:50






err: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'url' of undefined

– blydex
Mar 30 at 8:50














I fixed an issue in my code. Can you try it again please @blydex

– Gilles Heinesch
Mar 30 at 8:55





I fixed an issue in my code. Can you try it again please @blydex

– Gilles Heinesch
Mar 30 at 8:55




1




1





it works now, tysm :)

– blydex
Mar 30 at 9:03





it works now, tysm :)

– blydex
Mar 30 at 9:03




















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%2f55403855%2fgetting-an-image-url-from-a-message%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

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?