Skip to content

Commit

Permalink
add loging
Browse files Browse the repository at this point in the history
  • Loading branch information
Kry9toN committed Jan 23, 2021
1 parent 706a5aa commit c215108
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/command/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
} catch (e) {
console.log('Error : %s', color(e, 'red'))
client.reply('Gagal menambahkan target, mungkin karena di private')
client.log(e)
}
}
}
4 changes: 4 additions & 0 deletions src/command/gmium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
}).catch((err) => {
client.reply(pesan.gagal)
console.log(err)
client.log(err)
})
} else {
databaseInput(`INSERT INTO gmium(gid, lifetime, signature) VALUES('${gid}', 'standard', '${sign}')`)
Expand All @@ -28,6 +29,7 @@ module.exports = {
}).catch((err) => {
client.reply(pesan.gagal)
console.log(err)
client.log(err)
})
}
} else if (args[0] === 'del') {
Expand All @@ -37,6 +39,7 @@ module.exports = {
}).catch((err) => {
client.reply(pesan.gagal)
console.log(err)
client.log(err)
})
} else if (args.length === 0) {
await databaseView('SELECT * FROM gmium')
Expand All @@ -63,6 +66,7 @@ module.exports = {
}).catch((err) => {
client.reply('Error mengambil database')
console.log(err)
client.log(err)
})
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/command/nulis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module.exports = {
client.reply(pesan.tunggu)
const buffer = await getBuffer(hasil.result)
client.sendMessage(client.from, buffer, MessageType.image, { quoted: chat, caption: pesan.berhasil })
}).catch((err) => console.log(err))
}).catch((err) => {
console.log(err)
client.log(err)
})
}
}
5 changes: 4 additions & 1 deletion src/command/nulis2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module.exports = {
.then((hasil) => {
client.reply(pesan.tunggu)
client.sendMessage(client.from, hasil, MessageType.image, { quoted: chat, caption: pesan.berhasil })
}).catch((err) => console.log(err))
}).catch((err) => {
console.log(err)
client.log(err)
})
}
}
5 changes: 4 additions & 1 deletion src/command/nulis3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module.exports = {
client.reply(pesan.tunggu)
const image = await getBuffer(hasil.image)
client.sendMessage(client.from, image, MessageType.image, { quoted: chat, caption: pesan.berhasil })
}).catch((err) => console.log(err))
}).catch((err) => {
console.log(err)
client.log(err)
})
}
}
4 changes: 4 additions & 0 deletions src/command/sticker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
console.log(`[INFO] Error : ${err}`)
fs.unlinkSync(media)
client.reply('Error saat membuat sticker')
client.log(err)
})
.on('end', function () {
console.log('[INFO] Berhasil membuat sticker')
Expand All @@ -54,6 +55,7 @@ module.exports = {
fs.unlinkSync(media)
const tipe = media.endsWith('.mp4') ? 'video' : 'gif'
client.reply(`❌ Gagal, pada saat mengkonversi ${tipe} ke stiker`)
client.log(err)
})
.on('end', function () {
console.log('[INFO] Berhasil membuat sticker')
Expand Down Expand Up @@ -95,6 +97,8 @@ module.exports = {
.on('error', function (err) {
fs.unlinkSync(media)
console.log('[INFO] Error :', err)
client.reply('Error saat membuat sticker')
client.log(err)
})
.on('end', function () {
console.log('[INFO] Berhasil membuat sticker')
Expand Down
5 changes: 5 additions & 0 deletions src/krypton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ async function krypton () {
const content = JSON.stringify(chat.message)
const botNumber = client.user.jid
const ownerNumber = process.env.OWNER_PHONE // Isi di .env
const logGroup = process.env.LOGGING // Isi di .env
client.from = chat.key.remoteJid
client.isGroup = client.from.endsWith('@g.us')
client.sender = client.isGroup ? chat.participant : chat.key.remoteJid
Expand All @@ -142,6 +143,9 @@ async function krypton () {
client.mentions = (teks, id, bolean) => {
(bolean == null || bolean == undefined || bolean == false) ? client.sendMessage(client.from, teks.trim(), MessageType.extendedText, { contextInfo: { mentionedJid: id } }) : client.sendMessage(client.from, teks.trim(), MessageType.extendedText, { quoted: chat, contextInfo: { mentionedJid: id } })
}
client.log = (error: string) => {
client.sendMessage(logGroup, `[LOGGING] command: *${commandName}* ${error}`, MessageType.text)
}

client.isMedia = (type === 'imageMessage' || type === 'videoMessage')
client.isQuotedImage = type === 'extendedTextMessage' && content.includes('imageMessage')
Expand Down Expand Up @@ -231,6 +235,7 @@ async function krypton () {
} catch (e) {
console.log('[INFO] : %s', color(e, 'red'))
client.sendMessage(client.from, 'Telah terjadi error setelah menggunakan command ini.', MessageType.text)
client.log(e)
}
})
}
Expand Down

0 comments on commit c215108

Please sign in to comment.