@@ -189,28 +189,32 @@ class DigitalDiceManager {
189189 if ( ! rolled ) {
190190 // At the moment _makeRoll runs, React/MUI hasn’t finished updating the DOM for that toolbar yet.
191191 // so the roll buttons doesnt exist yet. We need to retry to roll the button a few times until it is done.
192- DigitalDiceManager . _clickRollButtonWithRetry ( ) ;
192+ rolled = await DigitalDiceManager . _clickRollButtonWithRetry ( ) ;
193193 }
194+ return rolled ;
194195 }
195- static _clickRollButtonWithRetry ( retries = 5 , delay = 50 ) {
196- const tryClick = ( remaining , _delay ) => {
197- const $rollButton = $ ( ".dice-toolbar.rollable .dice-toolbar__target button:not(.dice-toolbar__target-menu-button)" ) . first ( ) ;
196+ static async _clickRollButtonWithRetry ( retries = 5 , delay = 50 ) {
197+ return new Promise ( ( resolve ) => {
198+ const tryClick = ( remaining , _delay ) => {
199+ const $rollButton = $ ( ".dice-toolbar.rollable .dice-toolbar__target button:not(.dice-toolbar__target-menu-button)" ) . first ( ) ;
198200
199- if ( $rollButton . length ) {
200- $rollButton . click ( ) ;
201- return ;
202- }
201+ if ( $rollButton . length ) {
202+ $rollButton . click ( ) ;
203+ return resolve ( true ) ;
204+ }
203205
204- if ( remaining > 0 ) {
205- setTimeout ( ( ) => tryClick ( remaining - 1 , _delay ) , _delay ) ;
206- } else {
207- console . warn ( "DigitalDiceManager: roll button not found after retries" ) ;
208- }
209- } ;
206+ if ( remaining > 0 ) {
207+ setTimeout ( ( ) => tryClick ( remaining - 1 , _delay ) , _delay ) ;
208+ } else {
209+ console . warn ( "DigitalDiceManager: roll button not found after retries" ) ;
210+ return resolve ( false ) ;
211+ }
212+ } ;
210213
211- tryClick ( retries , delay ) ;
214+ tryClick ( retries , delay ) ;
215+ } ) ;
212216 }
213- static _selectWhisperTargetWithRetry ( retries = 5 , delay = 50 ) {
217+ static async _selectWhisperTargetWithRetry ( retries = 5 , delay = 50 ) {
214218 return new Promise ( ( resolve ) => {
215219 const menuButton = document . querySelector ( ".dice-toolbar.rollable button.dice-toolbar__target-menu-button" ) ;
216220 if ( ! menuButton ) {
0 commit comments