@neoxr/wb 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ on:
2
+ schedule:
3
+ # Timezone is UTC
4
+ # https://crontab.guru/#0_0_*_*_*
5
+ # At 00:00 every day.
6
+ - cron: '0 0 * * *'
7
+
8
+ # Allows us to manually trigger a nightly
9
+ # Since npm prevents duplicate releases we can run this at any time
10
+ # As long as the commit hash has changed on main a release will be published
11
+ workflow_dispatch: {}
12
+
13
+ permissions:
14
+ id-token: write
15
+
16
+ name: release-nightly
17
+
18
+ jobs:
19
+ release-nightly:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v3
23
+ run: npm publish --provenance --access public --tag=2.x
24
+ env:
25
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name":"@neoxr/wb",
3
- "version":"2.0.0",
3
+ "version":"2.1.0",
4
4
  "description":"Simplicity WhatsApp Bot (Baileys)",
5
5
  "main":"index.js",
6
6
  "scripts":{
7
- "test":"echo \"Error: no test specified\" && exit 1"
7
+ "test":"node ./example/index.js"
8
8
  },
9
9
  "repository":{
10
10
  "type":"git",
@@ -15,7 +15,8 @@
15
15
  "whatsapp-api",
16
16
  "bot",
17
17
  "whatsapp",
18
- "wabot"
18
+ "wabot",
19
+ "baileys"
19
20
  ],
20
21
  "author":"Wildan Izzudin",
21
22
  "license":"ISC",
@@ -44,7 +45,7 @@
44
45
  "jimp":"^0.16.1",
45
46
  "mime-types":"~2.1.32",
46
47
  "miniget": "^4.2.3",
47
- "mongodb":"npm:@neoxr/mongodb",
48
+ "mongodb":"4.x",
48
49
  "mongoose":"5.10.8",
49
50
  "moment-timezone":"~0.5.34",
50
51
  "node-cache":"^5.1.2",
package/system/mongo.js CHANGED
@@ -8,14 +8,19 @@ module.exports = class MongoDB {
8
8
  this._id = 1
9
9
  this.db = db || 'database'
10
10
  this.options = options
11
+ this.client = null
12
+ this.connection()
11
13
  this.init()
12
14
  }
13
15
 
14
- client = new MongoClient(process.env.DATABASE_URL, this.options)
16
+ connection = () => {
17
+ this.client = new MongoClient(process.env.DATABASE_URL, this.options)
18
+ this.client.connect()
19
+ }
15
20
 
16
21
  exec = async (collect) => {
17
22
  try {
18
- await this.client.connect()
23
+ // await this.client.connect()
19
24
  const db = await this.client.db(this.db).collection(collect)
20
25
  return db
21
26
  } catch (e) {
@@ -71,9 +76,14 @@ module.exports = class MongoDB {
71
76
  }
72
77
 
73
78
  init = async () => {
74
- await this.client.connect()
75
- const db = await this.client.db(this.db)
76
- const data = await (await db.listCollections().toArray()).some(v => v.name == 'data')
77
- if (!data) db.createCollection('data')
79
+ try {
80
+ // await this.client.connect()
81
+ const db = await this.client.db(this.db)
82
+ const data = await (await db.listCollections().toArray()).some(v => v.name == 'data')
83
+ if (!data) db.createCollection('data')
84
+ } catch (e) {
85
+ console.log(`System restarted because your mongodb connection error . . .`)
86
+ process.exit(1)
87
+ }
78
88
  }
79
89
  }