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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

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