@@ -22,30 +22,32 @@ wrap(() => {
2222 return null ;
2323 }
2424
25+ const events = [ 'chat-legendary-notification' , 'chat-legendary-shiny-notification' ] ;
2526 eventManager . on ( 'preChat:getMessageAuto' , function drawAnnouncement ( data ) {
27+ const message = JSON . parse ( JSON . parse ( data . message ) . args ) ;
28+ if ( this . canceled || ! events . includes ( message [ 0 ] ) ) return ;
2629 const setting = settings . value ( 'underscript.announcement.draws' ) ;
27- const index = data . message . indexOf ( ' has just obtained ' ) ;
28- if ( this . canceled || setting === 'chat' || ! ~ index ) return ;
30+ if ( setting === 'chat' ) return ;
2931 const both = setting === 'both' ;
3032 this . canceled = ! both ;
3133 if ( both || setting === 'toast' ) {
32- const owner = data . message . substring ( 0 , index ) ;
33- const card = data . message . substring ( index + 19 , data . message . length - 2 ) ;
34+ const owner = message [ 1 ] ;
35+ const card = message [ 2 ] ;
3436
3537 const last = getToast ( owner ) ;
3638 if ( last ) {
37- const text = `${ owner } has just obtained ${ last . cards . join ( ', ' ) } and ${ card } !` ;
38- last . setText ( text ) ;
39- last . time = Date . now ( ) ; // This toast is still relevant!
4039 last . cards . push ( card ) ;
40+ message [ 2 ] = last . cards . join ( ', ' ) ;
41+ last . setText ( translateFromServerJson ( JSON . stringify ( { args : JSON . stringify ( message ) } ) ) ) ;
42+ last . time = Date . now ( ) ; // This toast is still relevant!
4143 return ;
4244 }
4345 if ( toasts [ toastIndex ] ) { // Close any old toast
4446 toasts [ toastIndex ] . close ( ) ;
4547 }
46-
48+
4749 const toast = fn . toast ( {
48- text : data . message ,
50+ text : translateFromServerJson ( data . message ) ,
4951 css : {
5052 color : 'yellow' ,
5153 footer : { color : 'white' } ,
0 commit comments