name: Chuchoter aux joueurs type: script author: Hp9ImM4o9YRTSdfu img: icons/svg/deaf.svg scope: global command: >- /** * Provides a dialog to whisper specific players. If you have tokens selected, it will automatically default to try and whisper those players. * @Author: Nelson#3570 */ let applyChanges = false; let users = game.users.filter(user => user.active); let checkOptions = "" let playerTokenIds = users.map(u => u.character?.id).filter(id => id !== undefined); let selectedPlayerIds = canvas.tokens.controlled.map(token => { if (playerTokenIds.includes(token.actor.id)) return token.actor.id; }); // Build checkbox list for all active players users.forEach(user => { let checked = !!user.character && selectedPlayerIds.includes(user.character.id) && 'checked'; checkOptions+=`
\n ` }); new Dialog({ title:"Whisper", content:`Whisper To: ${checkOptions}

`, buttons:{ whisper:{ label:"Whisper", callback: (html) => createMessage(html) } } }).render(true); function createMessage(html) { var targets = []; // build list of selected players ids for whispers target for ( let user of users ) { if (html.find('[name="'+user.id+'"]')[0].checked){ applyChanges=true; targets.push(user.id); } var messageText = html.find('[name="message"]')[0].value } if(!applyChanges)return; ChatMessage.create({ content: messageText, whisper: targets }); } flags: core: sourceId: Compendium.foundry_community_macros.community-macros-misc.QTDeg4HOYCAmr4dK ownership: default: 2 Hp9ImM4o9YRTSdfu: 3 _stats: systemId: foundryvtt-reve-de-dragon systemVersion: 11.1.0 coreVersion: '12.331' createdTime: 1671237211578 modifiedTime: 1671237211578 lastModifiedBy: Hp9ImM4o9YRTSdfu compendiumSource: Compendium.foundry_community_macros.community-macros-misc.QTDeg4HOYCAmr4dK duplicateSource: null folder: null sort: 0 _id: ALAVJEEP3iJosOoi _key: '!macros!ALAVJEEP3iJosOoi'