-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathWhisperbox Macro.js
30 lines (26 loc) · 1.04 KB
/
Whisperbox Macro.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//This code works with WhisperBox. Save it as a macro to give yourself an alternative method
//of launching a WhisperBox that will also work for players.
var users = game.users.contents;
var selectOptions = ""
users.forEach(user => selectOptions += `<option value = "${user.id}">${user.name}</option>\n`);
var dp = {
title: "Create a WhisperBox",
content: `Pick a user:<select id="users" name="users">${selectOptions}</select>`,
//default:"whisper",
buttons: {
whisper: {
label: "Whisper",
callback: () => {
let uid = document.getElementById("users").value;
let user = game.users.find(user => user.id === uid);
let name = user.name;
if (game.settings.get('WhisperBox', 'showCharacterName')) {
name = user?.character?.name ?? name;
}
WhisperBox.createWhisperBox({name: name, targetUser: uid});
}
}
}
}
let d = new Dialog(dp);
d.render(true);