This snippet will format the referenced message into code block using command prefix. You have to click "Reply" to a message, enter the prefix, and add a code block style (e.g. js, html, css). See comments for more details.
/**
* Note that you have to reply to a message
* Then you can input the prefix + style
* Examples:
* .codeblock js
* .codeblock html
* .codeblock css
*/
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const REF_MESSAGE = context.params.event.referenced_message;
const style = context.params.event.content.split(' ')[1];
//If you have replied to a message, this will format that message, and removes your command
if(REF_MESSAGE){
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '```'+ style + '\n' + REF_MESSAGE.content + '\n```'
});
await lib.discord.channels['@0.3.2'].messages.destroy({
message_id: `${context.params.event.id}`,
channel_id: `${context.params.event.channel_id}`
});
}else{
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Hey <@!${context.params.event.author.id}>, reply to a message!`
});
}