If someone posts a message with an attached image, takes that image and puts it in an embed.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
if (context.params.event.content.startsWith('!embed')) {
if (context.params.event.attachments.length) {
await lib.discord.channels['@0.1.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Here is your embedded image!`,
embed: {
image: {
url: context.params.event.attachments[0].url
}
}
});
} else {
await lib.discord.channels['@0.1.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `You must attach an image to your message when using this command.`
});
}
}