Professional Documents
Culture Documents
function embedText( e ) {
for ( var i = 0; i < response.length; i++ ) {
const question = response[ i ].getItem().getTitle();
const answer = response[ i ].getResponse();
if ( answer == "" ) continue;
items.push( { "name": question, "value": answer } );
function data( item ) { return [ `**${ item.name }**`,`${ item.value }` ].join( "\n" ); }
}
try {
if ( avatarImage !== null ) {
const embedSetup = { "method": "post", "headers": { "Content-Type": "application/json" },
muteHttpExceptions: true, "payload": JSON.stringify( { "content": ( mention ) ? `${ mention }` : "
", "embeds": [ { "title": ( title ) ? title : form.getTitle(), "thumbnail": { "url": encodeURI( avatarImage
) }, "color": ( colour ) ? parseInt(colour.substr(1), 16) : Math.floor( Math.random() * 16777215 ),
"description": ( shortDescription ) ? `${ shortDescription }\n\n${ items.map( data ).join( '\n\n' ) }` :
items.map( data ).join( '\n\n' ), "timestamp": new Date().toISOString(), } ] } ) };
for ( var i = 0; i < webhooks.length; i++ ) { UrlFetchApp.fetch( webhooks[ i ], embedSetup
); }
return form.deleteResponse( latestResponse.getId() );
} else {
const embedSetup = { "method": "post", "headers": { "Content-Type": "application/json" },
muteHttpExceptions: true, "payload": JSON.stringify( { "content": ( mention ) ? `${ mention }` : "
", "embeds": [ { "title": ( title ) ? title : form.getTitle(), "color": ( colour ) ? parseInt(colour.substr(1),
16) : Math.floor( Math.random() * 16777215 ), "description": ( shortDescription ) ? `${
shortDescription }\n\n${ items.map( data ).join( '\n\n' ) }` : items.map( data ).join( '\n\n' ),
"timestamp": new Date().toISOString(), } ] } ) };
for ( var i = 0; i < webhooks.length; i++ ) { UrlFetchApp.fetch( webhooks[ i ], embedSetup
); }
return form.deleteResponse( latestResponse.getId() );
}
} catch(error) {
return Logger.log(error);
}
}