fdgt-apis/api

View on GitHub
src/helpers/renderMessage.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
// Local imports
import renderTemplate from 'helpers/renderTemplate'
import serializeTwitchObject from 'helpers/serializeTwitchObject'





export default options => {
    const {
        args,
        channel,
        connection,
        template,
        user,
    } = options

    try {
        const renderedTemplate = renderTemplate({
            args,
            channel,
            connection,
            template,
            user,
        })
        return `@${serializeTwitchObject(renderedTemplate.tags)} :${renderedTemplate.message}`
    } catch (error) {
        return null
    }
}