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;
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
add a comment
|
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
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
add a comment
|
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
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
node.js discord discord.js
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
add a comment
|
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
add a comment
|
1 Answer
1
active
oldest
votes
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 );
);
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
|
show 3 more comments
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
);
);
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%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
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 );
);
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
|
show 3 more comments
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 );
);
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
|
show 3 more comments
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 );
);
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 );
);
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
|
show 3 more comments
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
|
show 3 more comments
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%2f55403855%2fgetting-an-image-url-from-a-message%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
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