Implement Spell send to chat

This commit is contained in:
Oliver-Akins 2024-01-26 22:43:26 -07:00
parent b30aa18a27
commit efc9316c31
3 changed files with 24 additions and 1 deletions

View file

@ -57,6 +57,25 @@ export class ActorHandler extends Actor {
this.fn?.[`createCustom${data.embeddedCreate}`].bind(this)($event);
};
async genericSendToChat($event) {
const data = $event.currentTarget.dataset;
const type = data.messageType;
console.log(data)
if (this.fn?.[`send${type}ToChat`]) {
return await this.fn?.[`send${type}ToChat`].bind(this)($event);
};
if (!data.messageContent) {
console.warn(`.dungeon | Tried to send a chat message with no content`);
return;
};
let message = await ChatMessage.create({
content: data.messageContent,
flavor: data.messageFlavor,
speaker: { actor: this.actor }
});
message.render();
};
/**
* @param {ItemHandler} item
* @returns {boolean} true to allow the document to be embedded

View file

@ -49,6 +49,8 @@ export class GenericActorSheet extends ActorSheet {
.on(`click`, this.actor.genericEmbeddedDelete.bind(this.actor));
html.find(`[data-embedded-create]`)
.on(`click`, this.actor.genericEmbeddedCreate.bind(this.actor));
html.find(`[data-message-type]`)
.on(`click`, this.actor.genericSendToChat.bind(this.actor));
html.find(`[data-embedded-edit]`)
.on(`click`, this.actor.openEmbeddedSheet.bind(this.actor));
};