-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcardDrawPlacement.js
More file actions
30 lines (29 loc) · 861 Bytes
/
cardDrawPlacement.js
File metadata and controls
30 lines (29 loc) · 861 Bytes
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
(() => {
settings.register({
name: 'Card Draw Announcement',
key: 'underscript.announcement.draws',
type: 'select',
options: ['chat', 'toast', 'hidden'],
page: 'Chat',
});
const toasts = [];
let toastIndex = 0;
eventManager.on('preChat:getMessageAuto', function drawAnnouncement(data) {
const setting = settings.value('underscript.announcement.draws');
if (this.canceled || setting === 'chat' || !data.message.includes('has just obtained')) return;
this.canceled = true;
if (setting === 'toast') {
if (toasts[toastIndex % 3]) { // Close any old toast
toasts[toastIndex % 3].close();
}
toasts[toastIndex % 3] = fn.toast({
text: data.message,
css: {
color: 'yellow',
footer: {color: 'white'},
}
});
toastIndex += 1;
}
});
})();