Appel à la chance sur les défenses

Suppressions de ChatMessage selon contenu

En ayant un <div id=""> avec id unique, on peut retrouver et supprimer
les messages obsoletes (par exemple, les choix dans les combats).
This commit is contained in:
Vincent Vandemeulebrouck
2021-01-07 00:32:22 +01:00
parent 212a94afee
commit 47fb2d511e
6 changed files with 212 additions and 67 deletions

View File

@ -3,6 +3,12 @@
* Class providing helper methods to get the list of users, and
*/
export class ChatUtility {
static removeMyChatMessageContaining(part) {
const toDelete = game.messages.filter(it => it.user._id == game.user._id)
.filter(it => it.data.content.includes(part))
.forEach(it => it.delete());
}
/* -------------------------------------------- */
static chatWithRollMode(chatOptions, name) {
@ -11,7 +17,7 @@ export class ChatUtility {
}
/* -------------------------------------------- */
static createChatMessage( chatOptions, rollMode, name) {
static createChatMessage(chatOptions, rollMode, name) {
switch (rollMode) {
case "blindroll": // GM only
if (!game.user.isGM) {
@ -28,12 +34,12 @@ export class ChatUtility {
chatOptions.whisper = ChatUtility.getWhisperRecipients(rollMode, name);
break;
}
chatOptions.alias = chatOptions.alias||name;
chatOptions.alias = chatOptions.alias || name;
ChatMessage.create(chatOptions);
}
/* -------------------------------------------- */
static prepareChatMessage( rollMode, name) {
static prepareChatMessage(rollMode, name) {
return {
user: game.user._id,
whisper: ChatUtility.getWhisperRecipients(rollMode, name)
@ -41,7 +47,7 @@ export class ChatUtility {
}
/* -------------------------------------------- */
static getWhisperRecipients( rollMode, name) {
static getWhisperRecipients(rollMode, name) {
switch (rollMode) {
case "blindroll": return ChatUtility.getUsers(user => user.isGM);
case "gmroll": return ChatUtility.getWhisperRecipientsAndGMs(name);