Skip to content

Commit f6c9203

Browse files
committed
fix: study roll journal entry fix
1 parent c0d65bc commit f6c9203

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

module/helpers/study-roll.mjs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,16 @@ async function handleStudyRollCallback(app, actor, studyValue) {
361361
const imgSrc = actor.img;
362362
let tableContent = difficulty === 'Failed' ? '' : makeTable(actor, difficulty);
363363

364-
const entry = await JournalEntry.create({
364+
const journalEntryData = {
365365
name: actor.name,
366-
content: `
366+
folder: folderId,
367+
permission: { default: CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER },
368+
};
369+
370+
const JournalEntryClass = getDocumentClass('JournalEntry');
371+
const journalEntry = await JournalEntryClass.create(journalEntryData);
372+
373+
const pageContent = `
367374
<div style="
368375
background-color: #fff;
369376
box-shadow: #1a1c1833 0px 2px 1px -1px, #1a1c1824 0px 1px 1px 0px, #1a1c181f 0px 1px 3px 0px;
@@ -384,14 +391,20 @@ async function handleStudyRollCallback(app, actor, studyValue) {
384391
${tableContent}
385392
</div>
386393
</div>
387-
`,
388-
folder: folderId,
389-
permission: {
390-
default: 3,
394+
`;
395+
396+
const pageData = {
397+
name: actor.name,
398+
type: 'text',
399+
text: {
400+
content: pageContent,
401+
format: CONST.JOURNAL_ENTRY_PAGE_FORMATS.HTML,
391402
},
392-
});
403+
};
404+
405+
await journalEntry.createEmbeddedDocuments('JournalEntryPage', [pageData]);
393406

394-
const entryLink = `@JournalEntry[${entry.id}]{${entry.name}}`;
407+
const entryLink = `@JournalEntry[${journalEntry.id}]{${journalEntry.name}}`;
395408
let msg = (replacement ? update : update2) + `${entryLink}.`;
396409

397410
ChatMessage.create({

0 commit comments

Comments
 (0)