'How to send images on discord.js node js?
i have problem with sending images from url when i try to make bot discord, i got the messages " Hello " but not with the images.
require('dotenv').config();
const Discord = require("discord.js");
const client = new Discord.Client({intents: ["GUILDS", "GUILD_MESSAGES"]});
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on("message", msg => {
if (msg.content === "p") {
msg.reply("Hello", {files: ["https://s.imgur.com/images/logo-1200-630.jpg?2"]});
}
})
client.login(process.env.DISCORD_TOKEN);
Solution 1:[1]
The best way is to use MessageAttachment like discord.js intended.
const image = new Discord.MessageAttachment("https://s.imgur.com/images/logo-1200-630.jpg?2","img.png");
msg.reply({ files : [image] })
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Malik Lahlou |