@@ -387,6 +387,7 @@ export class Client {
387387 if ( ! emojiId ) return ;
388388 await this . _autoEmojiQ . add ( async ( ) => this . sendEmoji ( message . from , emojiId , message . id ) . catch ( ( ) => { } ) )
389389 }
390+ return message
390391 } )
391392 this . _autoEmojiSet = true ;
392393 }
@@ -811,7 +812,7 @@ export class Client {
811812
812813
813814 // STANDARD SIMPLE LISTENERS
814- private async preprocessMessage ( message : Message ) : Promise < Message > {
815+ private async preprocessMessage ( message : Message , source : 'onMessage' | 'onAnyMessage' ) : Promise < Message > {
815816 let alreadyProcessed = false ;
816817 if ( this . _preprocIdempotencyCheck [ message . id ] ) {
817818 log . info ( `preprocessMessage: ${ message . id } already being processed` )
@@ -839,8 +840,8 @@ export class Client {
839840 const start = Date . now ( )
840841 if ( typeof preproc === "function" ) {
841842 custom = true ;
842- _m = await preproc ( _m , this , alreadyProcessed )
843- } else if ( typeof preproc === "string" && MessagePreprocessors [ preproc ] ) _m = await MessagePreprocessors [ preproc ] ( _m , this , alreadyProcessed )
843+ _m = await preproc ( _m , this , alreadyProcessed , source )
844+ } else if ( typeof preproc === "string" && MessagePreprocessors [ preproc ] ) _m = await MessagePreprocessors [ preproc ] ( _m , this , alreadyProcessed , source )
844845 log . info ( `Preproc ${ custom ? 'CUSTOM' : preproc } ${ index } ${ fil } ${ message . id } ${ m . id } ${ Date . now ( ) - start } ms` )
845846 return _m ;
846847 } ) )
@@ -861,7 +862,7 @@ export class Client {
861862 * @fires [[Message]]
862863 */
863864 public async onMessage ( fn : ( message : Message ) => void , queueOptions ?: Options < PriorityQueue , DefaultAddOptions > ) : Promise < Listener | boolean > {
864- const _fn = async ( message : Message ) => fn ( await this . preprocessMessage ( message ) )
865+ const _fn = async ( message : Message ) => fn ( await this . preprocessMessage ( message , 'onMessage' ) )
865866 return this . registerListener ( SimpleListener . Message , _fn , this ?. _createConfig ?. pQueueDefault || queueOptions ) ;
866867 }
867868
@@ -874,7 +875,7 @@ export class Client {
874875 * @fires [[Message]]
875876 */
876877 public async onAnyMessage ( fn : ( message : Message ) => void , queueOptions ?: Options < PriorityQueue , DefaultAddOptions > ) : Promise < Listener | boolean > {
877- const _fn = async ( message : Message ) => fn ( await this . preprocessMessage ( message ) )
878+ const _fn = async ( message : Message ) => fn ( await this . preprocessMessage ( message , 'onAnyMessage' ) )
878879 return this . registerListener ( SimpleListener . AnyMessage , _fn , this ?. _createConfig ?. pQueueDefault || queueOptions ) ;
879880 }
880881
0 commit comments