Skip to content

Commit

Permalink
clean up source
Browse files Browse the repository at this point in the history
  • Loading branch information
Kry9toN committed Jan 20, 2021
1 parent 97d56ce commit 4c3e31c
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 121 deletions.
Binary file removed assets/fonts/KeepCalm-Medium.ttf
Binary file not shown.
Binary file removed assets/fonts/LuckiestGuy-Regular.ttf
Binary file not shown.
Binary file removed assets/fonts/SketchMatch.ttf
Binary file not shown.
Binary file removed assets/fonts/theboldfont.ttf
Binary file not shown.
Binary file removed assets/img/1px.png
Binary file not shown.
Binary file removed assets/img/default-avatar.png
Binary file not shown.
4 changes: 2 additions & 2 deletions command/add.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { MessageType } = require('@adiwajshing/baileys')
const { color } = require('../utils/color')

module.exports = {
name: 'add',
aliases: ['ad'],
description: 'Untuk menambahkan orang ke group dengan nomor\nPenggunaan: !add 6285xxxx',
// eslint-disable-next-line no-shadow-restricted-names
execute (client, undefined, pesan, args) {
if (!client.isGroup) return client.reply(pesan.error.group)
if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin)
Expand All @@ -17,6 +17,6 @@ module.exports = {
} catch (e) {
console.log('Error : %s', color(e, 'red'))
client.reply('Gagal menambahkan target, mungkin karena di private')
}
}
}
}
6 changes: 2 additions & 4 deletions command/clearall.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { MessageType } = require('@adiwajshing/baileys')

module.exports = {
name: 'clearall',
aliases: ['ca'],
Expand All @@ -9,8 +7,8 @@ module.exports = {
if (!isOwner) return reply('Kamu siapa?')
chatAll = client.chats.all()
client.setMaxListeners(25)
for (let chat of chatAll) {
client.deleteChat(chat.jid)
for (const chat of chatAll) {
client.deleteChat(chat.jid)
}
client.reply('Berhasil menghapus semua chat')
}
Expand Down
4 changes: 1 addition & 3 deletions command/demote.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { MessageType } = require('@adiwajshing/baileys')

module.exports = {
name: 'demote',
aliases: ['dm'],
Expand All @@ -12,7 +10,7 @@ module.exports = {
mentioned = chat.message.extendedTextMessage.contextInfo.mentionedJid
if (mentioned.length > 1) {
teks = 'Perintah di terima, demote :\n'
for (let _ of mentioned) {
for (const _ of mentioned) {
teks += `@${_.split('@')[0]}\n`
}
client.mentions(teks, mentioned, true)
Expand Down
18 changes: 8 additions & 10 deletions command/help.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
const { MessageType } = require('@adiwajshing/baileys')

module.exports = {
name: 'help',
aliases: ['h'],
description: 'Menampilkan semua perintah dan deskripsi',
execute (client, chat, pesan, args) {
const commands = client.cmd.array()
if (args.length == 0) {
let text = `Daftar perintah di bot ini\n\nPrefix: !\n`
commands.forEach((cmd) => {
text += `- *${cmd.name}* ${cmd.aliases ? `(${cmd.aliases})` : ''}\n`
})
return client.reply(text)
let text = 'Daftar perintah di bot ini\n\nPrefix: !\n'
commands.forEach((cmd) => {
text += `- *${cmd.name}* ${cmd.aliases ? `(${cmd.aliases})` : ''}\n`
})
return client.reply(text)
} else {
if (!client.cmd.has(args[0])) return client.reply('Perintah yang anda maksut tidak ada bro')
const text = client.cmd.get(args[0]).description
return client.reply(text)
if (!client.cmd.has(args[0])) return client.reply('Perintah yang anda maksut tidak ada bro')
const text = client.cmd.get(args[0]).description
return client.reply(text)
}
}
}
5 changes: 1 addition & 4 deletions command/hidetag.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { MessageType } = require('@adiwajshing/baileys')

module.exports = {
name: 'hidetag',
aliases: ['ht'],
Expand All @@ -8,9 +6,8 @@ module.exports = {
if (!client.isGroup) return client.reply(pesan.error.group)
if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin)
const value = client.body.slice(9)
const group = client.groupMetadata(client.from)
const memberList = []
for (let member of client.groupMembers) {
for (const member of client.groupMembers) {
memberList.push(member.jid)
}
const options = {
Expand Down
4 changes: 1 addition & 3 deletions command/kick.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { MessageType } = require('@adiwajshing/baileys')

module.exports = {
name: 'kick',
aliases: ['k'],
Expand All @@ -12,7 +10,7 @@ module.exports = {
mentioned = chat.message.extendedTextMessage.contextInfo.mentionedJid
if (mentioned.length > 1) {
teks = 'Perintah di terima, mengeluarkan :\n'
for (let _ of mentioned) {
for (const _ of mentioned) {
teks += `@${_.split('@')[0]}\n`
}
client.mentions(teks, mentioned, true)
Expand Down
12 changes: 6 additions & 6 deletions command/nulis.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ module.exports = {
description: 'Untuk menuliskan di buku bot\nPenggunaan !nulis _tulisan_',
execute (client, chat, pesan, args) {
const value = args.slice().join(' ')
fetchJson(`https://mhankbarbar.tech/nulis?text=${value}&apiKey=${client.apiKey}`, {method: 'get'})
.then(async (hasil) => {
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))
fetchJson(`https://mhankbarbar.tech/nulis?text=${value}&apiKey=${client.apiKey}`, { method: 'get' })
.then(async (hasil) => {
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))
}
}
9 changes: 4 additions & 5 deletions command/nulis2.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { MessageType } = require('@adiwajshing/baileys')
const { getBuffer } = require('../utils/functions')
const { fetchJson } = require('../utils/fetcher')

module.exports = {
name: 'nulis2',
Expand All @@ -9,9 +8,9 @@ module.exports = {
execute (client, chat, pesan, args) {
const value = args.slice().join(' ')
getBuffer(`https://api.zeks.xyz/api/nulis?text=${value}&apikey=administrator`)
.then((hasil) => {
client.reply(pesan.tunggu)
client.sendMessage(client.from, hasil, MessageType.image, {quoted: chat, caption: pesan.berhasil})
}).catch((err) => console.log(err))
.then((hasil) => {
client.reply(pesan.tunggu)
client.sendMessage(client.from, hasil, MessageType.image, { quoted: chat, caption: pesan.berhasil })
}).catch((err) => console.log(err))
}
}
20 changes: 10 additions & 10 deletions krypton.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ async function krypton () {
if (!isCmd && client.isGroup) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;31mRECV\x1b[1;37m]', time, color('Message'), 'client.from', color(client.sender.split('@')[0]), 'in', color(groupName), 'args :', color(args.length))

pesan = {
tunggu: '⌛ Sedang di Prosess ⌛',
berhasil: '✔️ Berhasil ✔️',
hanya: {
admin: '❌ Perintah ini hanya bisa di gunakan oleh admin group! ❌',
botAdmin: '❌ Perintah ini hanya bisa di gunakan ketika bot menjadi admin! ❌'
},
error: {
group: '❌ Perintah ini hanya bisa di gunakan dalam group! ❌',
args: '❌ Perintah anda salah! ❌'
}
tunggu: '⌛ Sedang di Prosess ⌛',
berhasil: '✔️ Berhasil ✔️',
hanya: {
admin: '❌ Perintah ini hanya bisa di gunakan oleh admin group! ❌',
botAdmin: '❌ Perintah ini hanya bisa di gunakan ketika bot menjadi admin! ❌'
},
error: {
group: '❌ Perintah ini hanya bisa di gunakan dalam group! ❌',
args: '❌ Perintah anda salah! ❌'
}
}

/**
Expand Down
31 changes: 14 additions & 17 deletions utils/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@ const fetch = require('node-fetch')
const fs = require('fs')

exports.getBase64 = getBase64 = async (url) => {
const response = await fetch(url, { headers: { 'User-Agent': 'okhttp/4.5.0' } });
if (!response.ok) throw new Error(`unexpected response ${response.statusText}`);
const buffer = await response.buffer();
const videoBase64 = `data:${response.headers.get('content-type')};base64,` + buffer.toString('base64');
if (buffer)
return videoBase64;
};
const response = await fetch(url, { headers: { 'User-Agent': 'okhttp/4.5.0' } })
if (!response.ok) throw new Error(`unexpected response ${response.statusText}`)
const buffer = await response.buffer()
const videoBase64 = `data:${response.headers.get('content-type')};base64,` + buffer.toString('base64')
if (buffer) { return videoBase64 }
}

exports.getBuffer = getBuffer = async (url) => {
const res = await fetch(url, {headers: { 'User-Agent': 'okhttp/4.5.0'}, method: 'GET' })
const anu = fs.readFileSync('./src/emror.jpg')
if (!res.ok) return { type: 'image/jpeg', result: anu }
const buff = await res.buffer()
if (buff)
return { type: res.headers.get('content-type'), result: buff }
const res = await fetch(url, { headers: { 'User-Agent': 'okhttp/4.5.0' }, method: 'GET' })
const anu = fs.readFileSync('./src/emror.jpg')
if (!res.ok) return { type: 'image/jpeg', result: anu }
const buff = await res.buffer()
if (buff) { return { type: res.headers.get('content-type'), result: buff } }
}

exports.fetchJson = fetchJson = (url, options) => new Promise(async (resolve, reject) => {
exports.fetchJson = fetchJson = (url, options) => new Promise((resolve, reject) => {
fetch(url, options)
.then(response => response.json())
.then(json => {
Expand All @@ -31,8 +29,7 @@ exports.fetchJson = fetchJson = (url, options) => new Promise(async (resolve, re
})
})


exports.fetchText = fetchText = (url, options) => new Promise(async (resolve, reject) => {
exports.fetchText = fetchText = (url, options) => new Promise((resolve, reject) => {
fetch(url, options)
.then(response => response.text())
.then(text => {
Expand All @@ -44,4 +41,4 @@ exports.fetchText = fetchText = (url, options) => new Promise(async (resolve, re
})
})

//exports.getBase64 = getBase64;
// exports.getBase64 = getBase64;
42 changes: 21 additions & 21 deletions utils/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ const processTime = (timestamp, now) => {
}

const getGroupAdmins = (participants) => {
admins = []
for (let i of participants) {
i.isAdmin ? admins.push(i.jid) : ''
}
return admins
admins = []
for (const i of participants) {
i.isAdmin ? admins.push(i.jid) : ''
}
return admins
}

const banner = cfonts.render(('KRYPTON|WHATSAPP|BOT'), {
Expand All @@ -64,22 +64,22 @@ const banner = cfonts.render(('KRYPTON|WHATSAPP|BOT'), {
})

const getBuffer = async (url, options) => {
try {
options ? options : {}
const res = await axios({
method: "get",
url,
headers: {
'DNT': 1,
'Upgrade-Insecure-Request': 1
},
...options,
responseType: 'arraybuffer'
})
return res.data
} catch (e) {
console.log(`Error : ${e}`)
}
try {
options || {}
const res = await axios({
method: 'get',
url,
headers: {
DNT: 1,
'Upgrade-Insecure-Request': 1
},
...options,
responseType: 'arraybuffer'
})
return res.data
} catch (e) {
console.log(`Error : ${e}`)
}
}

module.exports = {
Expand Down
72 changes: 36 additions & 36 deletions utils/greeting.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
const Canvas = require('wa-canvas')

const welcome = (pushname, gcname, picprofil) => new Promise((resolve, reject) => {
async function welcome () {
const image = await new Canvas.Welcome()
.setUsername(pushname)
.setGuildName(gcname)
.setAvatar(picprofil)
.setColor("border", "#8015EA")
.setColor("username-box", "#8015EA")
.setColor("message-box", "#8015EA")
.setColor("title", "#8015EA")
.setColor("avatar", "#8015EA")
.toAttachment();
async function welcome () {
const image = await new Canvas.Welcome()
.setUsername(pushname)
.setGuildName(gcname)
.setAvatar(picprofil)
.setColor('border', '#8015EA')
.setColor('username-box', '#8015EA')
.setColor('message-box', '#8015EA')
.setColor('title', '#8015EA')
.setColor('avatar', '#8015EA')
.toAttachment()

const buff = image.toBuffer()
const base64 = `data:image/png;base64,${buff.toString('base64')}`
return base64
}
welcome().then((hasil) => resolve(hasil)).catch((err) => {
reject(err)
})
const buff = image.toBuffer()
const base64 = `data:image/png;base64,${buff.toString('base64')}`
return base64
}
welcome().then((hasil) => resolve(hasil)).catch((err) => {
reject(err)
})
})

const goodbye = (pushname, gcname, picprofil) => new Promise((resolve, reject) => {
async function goodbye () {
const image = await new Canvas.Goodbye()
.setUsername(pushname)
.setGuildName(gcname)
.setAvatar(picprofil)
.setColor("border", "#8015EA")
.setColor("username-box", "#8015EA")
.setColor("message-box", "#8015EA")
.setColor("title", "#8015EA")
.setColor("avatar", "#8015EA")
.toAttachment();
async function goodbye () {
const image = await new Canvas.Goodbye()
.setUsername(pushname)
.setGuildName(gcname)
.setAvatar(picprofil)
.setColor('border', '#8015EA')
.setColor('username-box', '#8015EA')
.setColor('message-box', '#8015EA')
.setColor('title', '#8015EA')
.setColor('avatar', '#8015EA')
.toAttachment()

const buff = image.toBuffer()
const base64 = `data:image/png;base64,${buff.toString('base64')}`
return base64
}
goodbye().then((hasil) => resolve(hasil)).catch((err) => {
reject(err)
})
const buff = image.toBuffer()
const base64 = `data:image/png;base64,${buff.toString('base64')}`
return base64
}
goodbye().then((hasil) => resolve(hasil)).catch((err) => {
reject(err)
})
})

module.exports = {
Expand Down

0 comments on commit 4c3e31c

Please sign in to comment.