const sanitizeHtml = require('sanitize-html') module.exports = { data: { "name": 'slavista', "usage": '', "description": 'Sends latest fediverse post made by slavistapl.' }, async execute(event, bot) { const response = await fetch('https://500plus.slavistapl.eu.org/api/v1/accounts/AajrBXKHPBH47ggKFU/statuses?exclude_replies=false&with_muted=true'); if (!response.ok) { event.reply("Couldn't fetch posts...") } else { const json = await response.json() let i = 0 let done = false do { if (i > json.length) { event.reply("Couldn't fetch posts...") done = true } else { if (json[i].content == "" && json[i].media_attachments.length == 0) { i++ } else { let str = sanitizeHtml(`${json[i].content.toString()} | ${json[i].uri}`, { allowedTags: ['a'], allowedAttributes: { 'a': ['href'] } }) event.reply(str) done = true } } } while (!done) } } }