Skip to content

Commit

Permalink
add new chatcommand to set next date
Browse files Browse the repository at this point in the history
  • Loading branch information
kvndrsslr committed Nov 1, 2022
1 parent cc312a3 commit 3e9dd64
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
5 changes: 1 addition & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ tinymce/
system.json
system.template.json
template.json
zweihander.css
zweihander.css.map
zweihander.js
zweihander.js.map
dist/
rollup.config.js
*.hbs
*.min.*
42 changes: 38 additions & 4 deletions src/module/zweihander.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Authors: Re4XN, kxfin
*/

import '../index.scss';
import '../index.scss';

import ZweihanderActor from './actor/actor';
import ZweihanderCharacterSheet from './actor/sheet/character-sheet';
Expand Down Expand Up @@ -38,7 +38,7 @@ import ZweihanderActiveEffectConfig from './apps/active-effect-config';
/* Foundry VTT Initialization */
/* -------------------------------------------- */

CONFIG.compatibility.mode = CONST.COMPATIBILITY_MODES.SILENT
CONFIG.compatibility.mode = CONST.COMPATIBILITY_MODES.SILENT;

const socket = new Promise((resolve) => {
Hooks.once('socketlib.ready', () => {
Expand Down Expand Up @@ -220,6 +220,40 @@ Hooks.on('chatCommandsReady', function (chatCommands) {
description: 'Do a Skill Test',
})
);
if (game.user.isGM) {
chatCommands.registerCommand(
chatCommands.createCommandFromData({
commandKey: '/nextSession',
invokeOnCommand: async (chatlog, messageText, chatdata) => {
const nextSession = new Date(messageText).toISOString();
const response = await foundry.utils.fetchJsonWithTimeout(
foundry.utils.getRoute('setup'),
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
id: game.world.id,
nextSession,
action: 'editWorld',
}),
}
);
game.world.updateSource(response);
await ChatMessage.create({
flavor: 'Setting the date for the next session.',
content: `
<h2>Next Session Date</h2>
The next session will be on ${nextSession}.
Please block the date in your calendars.
`,
});
},
shouldDisplayToChat: true,
iconClass: 'fa-calendar',
description: 'Set the date for the next session',
})
);
}
chatCommands.registerCommand(
chatCommands.createCommandFromData({
commandKey: '/help',
Expand Down Expand Up @@ -271,5 +305,5 @@ if (import.meta.hot) {
if (newModule) {
_module = newModule._module;
}
})
}
});
}

0 comments on commit 3e9dd64

Please sign in to comment.