Skip to content

Commit

Permalink
feat: Added WPP.conn.isMainReady function
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jun 7, 2022
1 parent ea6617e commit 66734d2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/conn/functions/isMainLoaded.ts
Expand Up @@ -17,7 +17,7 @@
import { Cmd } from '../../whatsapp';

/**
* Check is main interface is loaded and authenticated
* Check is main interface is authenticated and loaded, bot not synced
*
* @example
* ```javascript
Expand Down
35 changes: 35 additions & 0 deletions src/conn/functions/isMainReady.ts
@@ -0,0 +1,35 @@
/*!
* Copyright 2022 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { internalEv } from '../../eventEmitter';

let isReady = false;

internalEv.once('conn.main_ready', () => {
isReady = true;
});

/**
* Check is main interface is authenticated, loaded and synced
*
* @example
* ```javascript
* const isMainReady = WPP.conn.isMainReady();
* ```
*/
export function isMainReady(): boolean {
return isReady;
}

0 comments on commit 66734d2

Please sign in to comment.