diff --git a/module/chat-utility.js b/module/chat-utility.js index 2d71979c..be3c737b 100644 --- a/module/chat-utility.js +++ b/module/chat-utility.js @@ -3,12 +3,35 @@ * Class providing helper methods to get the list of users, and */ export class ChatUtility { + + static onSocketMessage(sockmsg) { + switch (sockmsg.msg) { + case "msg_delete_chat_message": return ChatUtility.onRemoveMessages(sockmsg.part, sockmsg.gmId); + } + } + + static onRemoveMessages(part, gmId) { + if (game.user._id == gmId) { + const toDelete = game.messages.filter(it => it.data.content.includes(part)); + toDelete.forEach(it => it.delete()); + } + + } /* -------------------------------------------- */ - static removeMyChatMessageContaining(part) { - const toDelete = game.messages.filter(it => it.user._id == game.user._id) - .filter(it => it.data.content.includes(part)); - toDelete.forEach(it => it.delete()); + static removeChatMessageContaining(part) { + const gmId = game.user.isGM ? game.user._id : game.users.entities.find(u => u.isGM)?.id; + + if (!gmId || game.user.isGM) { + ChatUtility.onRemoveMessages(part, game.user._id); + } + else { + game.socket.emit("system.foundryvtt-reve-de-dragon", { + msg: "msg_delete_chat_message", data: { + part:part, + gmId: gmId, + }}); + } } /* -------------------------------------------- */ diff --git a/module/rdd-combat.js b/module/rdd-combat.js index d4cd0726..06e115cc 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -44,18 +44,18 @@ export class RdDCombat { /* -------------------------------------------- */ static onPreDeleteCombat(combat, options) { if (game.user.isGM) { - ChatUtility.removeMyChatMessageContaining(`
/aide
dans le chat permet de voir les commandes spécifiques à Rêve de Dragon./aide
dans le chat permet de voir les commandes spécifiques à Rêve de Dragon.