Skip to content

Commit e7d54bd

Browse files
committed
chore(deps): bump @neoxr/wb from 6.0.0-rc.10 to 6.0.0-rc.11 and baileys from 7.0.0-rc.3 to 7.0.0-rc.5
feat(update): initialize database fix: group creator
1 parent 35b18ec commit e7d54bd

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

client.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,20 @@ const connect = async () => {
5151
}
5252
})
5353

54-
client.register('connect', async ctx => {
55-
global.db = { users: [], chats: [], groups: [], statistic: {}, sticker: {}, setting: {}, ...(await system.database.fetch() || {}) }
56-
await system.database.save(global.db)
57-
if (ctx && typeof ctx === 'object' && ctx.message) Utils.logFile(ctx.message)
54+
client.once('connect', async res => {
55+
try {
56+
const defaults = { users: [], chats: [], groups: [], statistic: {}, sticker: {}, setting: {}, ...(await system.database.fetch() || {}) }
57+
const previous = await system.database.fetch()
58+
if (!previous || typeof previous !== 'object' || !Object.keys(previous).length) {
59+
global.db = defaults
60+
await system.database.save(defaults)
61+
} else {
62+
global.db = previous
63+
}
64+
} catch (e) {
65+
Utils.printError(e)
66+
}
67+
if (res && typeof res === 'object' && res.message) Utils.logFile(res.message)
5868
})
5969

6070
client.register('error', async error => {

handler.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ export default async (client, ctx) => {
3333
const isAdmin = m.isGroup ? admins.includes(m.sender) : false
3434
const isBotAdmin = m.isGroup ? admins.includes((client.user.id.split`:`[0]) + '@s.whatsapp.net') : false
3535

36+
if (!users || typeof users.limit === undefined) return global.db.users.push({
37+
jid: m.sender,
38+
lid: m.sender?.endsWith('lid') ? m.sender : null,
39+
banned: false,
40+
limit: Config.limit,
41+
hit: 0,
42+
spam: 0
43+
})
44+
3645
const isSpam = spam.detection(client, m, {
3746
prefix, command, commands, users, cooldown,
3847
show: 'all', // options: 'all' | 'command-only' | 'message-only' | 'spam-only'| 'none'
@@ -50,14 +59,6 @@ export default async (client, ctx) => {
5059
if (m.isGroup && !isBotAdmin) {
5160
groupSet.localonly = false
5261
}
53-
if (!users || typeof users.limit === undefined) return global.db.users.push({
54-
jid: m.sender,
55-
lid: m.sender?.endsWith('lid') ? m.sender : null,
56-
banned: false,
57-
limit: Config.limit,
58-
hit: 0,
59-
spam: 0
60-
})
6162
if (!setting.multiprefix) setting.noprefix = false
6263
if (setting.debug && !m.fromMe && isOwner) client.reply(m.chat, Utils.jsonFormat(m), m)
6364

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"homepage": "https://github.com/neoxr/neoxr-bot#readme",
2727
"dependencies": {
2828
"@adiwajshing/keyed-db": "^0.2.4",
29-
"@neoxr/wb": "^6.0.0-rc.10",
29+
"@neoxr/wb": "^6.0.0-rc.11",
3030
"audio-decode": "^2.1.3",
31-
"baileys": "^7.0.0-rc.3",
31+
"baileys": "^7.0.0-rc.5",
3232
"cfonts": "3.1.1",
3333
"html-entities": "^2.5.2",
3434
"node-gtts": "^2.0.2",

plugins/group/groupinfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const run = {
1212
}) => {
1313
try {
1414
const meta = await (await client.groupMetadata(m.chat))
15-
const creator = (meta?.owner?.endsWith('lid') ? meta?.ownerJid : meta.owner)?.replace(/@.+/, '')
15+
const creator = (meta?.owner?.endsWith('lid') ? (meta?.ownerJid ?? meta?.ownerPn) : meta.owner)?.replace(/@.+/, '')
1616
const admin = client.getAdmin(meta.participants)
1717
const member = participants.map(u => u.id)
1818
const picture = await client.profilePicture(m.chat)

plugins/userinfo/me.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const run = {
99
}) => {
1010
let user = global.db.users.find(v => v.jid == m.sender)
1111
let _own = [...new Set([Config.owner, ...global.db.setting.owners])]
12-
const avatar = await client.profilePicture(m.sender)
12+
const avatar = await client.profilePicture(m.sender)
1313
let blocked = blockList.includes(m.sender) ? true : false
1414
let now = new Date() * 1
1515
let lastseen = (user.lastseen == 0) ? 'Never' : Utils.toDate(now - user.lastseen)

0 commit comments

Comments
 (0)