@@ -728,13 +728,13 @@ export class Player extends EventEmitter<PlayerEventMap> {
728728 async lock (
729729 action : ( ) => PossiblyAsync < void > ,
730730 interaction ?: Interaction
731- ) : Promise < boolean > {
731+ ) : Promise < void > {
732732 let isLocked = this . isLocked ;
733733 const lockedAt = this . lockedAt ;
734734 this . locked = true ;
735- this . lockedAt = unix ( ) ;
735+ this . lockedAt ?? = unix ( ) ;
736736
737- if ( lockedAt !== null && isLocked && ( unix ( ) - ( lockedAt ?? 0 ) > 20 ) ) {
737+ if ( lockedAt !== null && isLocked && ( unix ( ) - lockedAt > 20 ) ) {
738738 gtaTunesLog ( 'PLAYER' , `Player lock in guild ${ p . magenta ( this . guild . name ) } (${ p . magenta ( this . guild . id ) } ) has expired, forcing unlock.` ) ;
739739 isLocked = false ;
740740 this . lockedAt = null ;
@@ -748,7 +748,7 @@ export class Player extends EventEmitter<PlayerEventMap> {
748748
749749 if ( interaction ) {
750750 await LockedPlayerError . handleInteraction ( this , interaction ) ;
751- return false ;
751+ return ;
752752 }
753753
754754 throw new LockedPlayerError ( this ) ;
@@ -759,26 +759,23 @@ export class Player extends EventEmitter<PlayerEventMap> {
759759 `Locking player in ${ p . magenta ( this . guild . name ) } (${ p . magenta ( this . guild . id ) } ).`
760760 ) ;
761761
762- try {
763- await action ( ) ;
764- } catch ( e ) {
762+ const unlock = ( ) => {
765763 gtaTunesLog (
766764 'PLAYER' ,
767- `Unlocking player in ${ p . magenta ( this . guild . name ) } (${ p . magenta ( this . guild . id ) } ) after failing action .`
765+ `Unlocking player in ${ p . magenta ( this . guild . name ) } (${ p . magenta ( this . guild . id ) } ).`
768766 ) ;
769767 this . locked = false ;
770768 this . lockedAt = null ;
771- throw e ;
772769 }
773770
774- gtaTunesLog (
775- 'PLAYER' ,
776- `Unlocking player in ${ p . magenta ( this . guild . name ) } ( ${ p . magenta ( this . guild . id ) } ).`
777- ) ;
778- this . locked = false ;
779- this . lockedAt = null ;
780-
781- return true ;
771+ try {
772+ await action ( ) ;
773+ setTimeout ( ( ) => unlock ( ) , 1500 ) ;
774+ } catch ( e ) {
775+ gtaTunesLog ( 'FAIL' , 'Locked player action failed' , e ) ;
776+ unlock ( ) ;
777+ throw e ;
778+ }
782779 }
783780}
784781
0 commit comments