When someone replies with "?geturl" to a message containing image attachment , the bot will send the image's url to the channel. Can be used for making image manipulation commands and all...
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const channel_id = context.params.event.channel_id ;
const message = context.params.event.content ;
const refmsg = context.params.event.referenced_message ;
var image_url = null ;
if (refmsg.attachments.length) {
const attachment = refmsg.attachments[0]
if (attachment.content_type.startsWith('image/'))
image_url = attachment.url // "image_url" is the replied message's image url!
}
await lib.discord.channels['@0.1.1'].messages.create({
channel_id: `${channel_id}`,
content: `Your image url: ${image_url}`,
});