Skip to content

Commit

Permalink
make strong type for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Kry9toN committed Jan 26, 2021
1 parent 1adb1c5 commit 2788c97
Show file tree
Hide file tree
Showing 25 changed files with 91 additions and 90 deletions.
2 changes: 1 addition & 1 deletion src/command/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
aliases: ['ad'],
cooldown: 20,
description: 'Untuk menambahkan orang ke group dengan nomor\nPenggunaan: !add 6285xxxx',
execute (client: any, chat: any, pesan: any, args:any) {
execute (client: any, chat: any, pesan: any, args: any) {
if (!client.isGroup) return client.reply(pesan.error.group)
if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin)
if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin)
Expand Down
2 changes: 1 addition & 1 deletion src/command/clearall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
name: 'clearall',
aliases: ['ca'],
description: 'Untuk benghapus semua chat _only owner_',
execute (client, chat, pesan) {
execute (client: any, chat: any, pesan: any) {
if (!client.isOwner) return client.reply('Kamu siapa?')
const chatAll = client.chats.all()
client.setMaxListeners(25)
Expand Down
2 changes: 1 addition & 1 deletion src/command/demote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
aliases: ['dm'],
cooldown: 10,
description: 'Untuk manghapus admin anggota group\nPenggunaan: !demote _quoted/tag_',
execute (client, chat, pesan) {
execute (client: any, chat: any, pesan: any) {
if (!client.isGroup) return client.reply(pesan.error.group)
if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin)
if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin)
Expand Down
2 changes: 1 addition & 1 deletion src/command/fakereply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
aliases: ['fr', 'fake', 'fitnah'],
cooldown: 35,
description: 'Untuk memfitnah atau menjahili teman\nPenggunaan !fakereply _tag_',
execute (client, chat, pesan) {
execute (client: any, chat: any, pesan: any) {
if (!client.isGroup) return client.reply(pesan.error.group)
const arg = client.body.slice(9)
const targets = arg.split('|')[1]
Expand Down
12 changes: 6 additions & 6 deletions src/command/gmium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
name: 'gmium',
aliases: ['gm'],
description: 'Untuk mengelola member premium group _only owner_',
async execute (client, chat, pesan, args) {
async execute (client: any, chat: any, pesan: any, args: any) {
if (!client.isOwner && !client.isSudo) return client.reply(pesan.hanya.owner)
const gid = args[1]
if (args[0] === 'add') {
Expand All @@ -17,7 +17,7 @@ module.exports = {
databaseInput(`INSERT INTO gmium(gid, lifetime, signature) VALUES('${gid}', 'unlimited', '${sign}')`)
.then(() => {
client.reply(pesan.berhasil)
}).catch((err) => {
}).catch((err: string) => {
client.reply(pesan.gagal)
console.log(err)
client.log(err)
Expand All @@ -26,7 +26,7 @@ module.exports = {
databaseInput(`INSERT INTO gmium(gid, lifetime, signature) VALUES('${gid}', 'standard', '${sign}')`)
.then(() => {
client.reply(pesan.berhasil)
}).catch((err) => {
}).catch((err: string) => {
client.reply(pesan.gagal)
console.log(err)
client.log(err)
Expand All @@ -36,14 +36,14 @@ module.exports = {
databaseInput(`DELETE FROM gmium WHERE gid = '${gid}'`)
.then(() => {
client.reply(pesan.berhasil)
}).catch((err) => {
}).catch((err: string) => {
client.reply(pesan.gagal)
console.log(err)
client.log(err)
})
} else if (args.length === 0) {
await databaseView('SELECT * FROM gmium')
.then((result) => {
.then((result: any) => {
let text = '📝 Daftar *Premium* di bot ini\n'
const mentioned = []
if (result.length > 0) {
Expand All @@ -63,7 +63,7 @@ module.exports = {
text += '- Belum ada member'
client.reply(text)
}
}).catch((err) => {
}).catch((err: string) => {
client.reply('Error mengambil database')
console.log(err)
client.log(err)
Expand Down
4 changes: 2 additions & 2 deletions src/command/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module.exports = {
aliases: ['h'],
cooldown: 10,
description: 'Menampilkan semua perintah dan deskripsi',
execute (client, chat, pesan, args) {
execute (client: any, chat: any, pesan: any, args: any) {
const commands = client.cmd.array()
if (args.length == 0) {
let text = 'Daftar perintah di bot ini\n\nPrefix: !\n'
commands.forEach((cmd) => {
commands.forEach((cmd: any) => {
text += `- *${cmd.name}* ${cmd.aliases ? `(${cmd.aliases})` : ''}\n`
})
text += '\nMasih bingung? ketik *!help <perintah>* akan menampilkan penggunaan perintah tersebut'
Expand Down
2 changes: 1 addition & 1 deletion src/command/hidetag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
aliases: ['ht'],
cooldown: 45,
description: 'Untuk mengetag semua orang tanpa @\nPenggunaan !hidetag _text_',
execute (client, chat, pesan) {
execute (client: any, chat: any, pesan: any) {
if (!client.isGroup) return client.reply(pesan.error.group)
if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin)
const value = client.body.slice(9)
Expand Down
2 changes: 1 addition & 1 deletion src/command/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
name: 'id',
cooldown: 10,
description: 'Untuk menampilkan id group/user\nPenggunaan: !id',
execute (client, chat, pesan) {
execute (client: any, chat: any, pesan: any) {
const uid = client.sender
if (client.isGroup) {
const gid = client.groupId
Expand Down
2 changes: 1 addition & 1 deletion src/command/kick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
aliases: ['k'],
cooldown: 10,
description: 'Untuk mengeluarkan angota di group\nPenggunaan: !kick _quoted/tag_',
execute (client, chat, pesan) {
execute (client: any, chat: any, pesan: any) {
if (!client.isGroup) return client.reply(pesan.error.group)
if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin)
if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin)
Expand Down
4 changes: 2 additions & 2 deletions src/command/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
name: 'notes',
cooldown: 15,
description: 'Untuk menyimpan note atau catatan di group\nPenggunaan: !notes <save/remove> <key> <value>',
async execute (client, chat, pesan, args) {
async execute (client: any, chat: any, pesan: any, args: any) {
if (!client.isGroup) return client.reply(pesan.error.group)
if (!client.isGmium) return client.reply(pesan.hanya.premium)
if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin)
Expand All @@ -15,7 +15,7 @@ module.exports = {
const res = arg.split('|')[2].trim()
if (args == 0) {
await databaseView('SELECT * FROM notes')
.then((hasil) => {
.then((hasil: any) => {
let text = 'Daftar *notes* di group ini\n\n'
if (hasil.length > 0) {
for (const list of hasil) {
Expand Down
6 changes: 3 additions & 3 deletions src/command/nulis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ module.exports = {
aliases: ['n'],
cooldown: 50,
description: 'Untuk menuliskan di buku bot\nPenggunaan !nulis _tulisan_',
execute (client, chat, pesan, args) {
execute (client: any, chat: any, pesan: any, args: any) {
const value = args.slice().join(' ')
fetchJson(`https://mhankbarbar.tech/nulis?text=${value}&apiKey=${client.apiKey}`, { method: 'get' })
.then(async (hasil) => {
.then(async (hasil: any) => {
client.reply(pesan.tunggu)
const buffer = await getBuffer(hasil.result)
client.sendMessage(client.from, buffer, MessageType.image, { quoted: chat, caption: pesan.berhasil })
}).catch((err) => {
}).catch((err: string) => {
console.log(err)
client.log(err)
})
Expand Down
6 changes: 3 additions & 3 deletions src/command/nulis2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ module.exports = {
aliases: ['n2'],
cooldown: 50,
description: 'Untuk menuliskan di buku bot\nPenggunaan !nulis2 _tulisan_',
execute (client, chat, pesan, args) {
execute (client: any, chat: any, pesan: any, args: any) {
const value = args.slice().join(' ')
getBuffer(`https://api.zeks.xyz/api/nulis?text=${value}&apikey=administrator`)
.then((hasil) => {
.then((hasil: any) => {
client.reply(pesan.tunggu)
client.sendMessage(client.from, hasil, MessageType.image, { quoted: chat, caption: pesan.berhasil })
}).catch((err) => {
}).catch((err: string) => {
console.log(err)
client.log(err)
})
Expand Down
6 changes: 3 additions & 3 deletions src/command/nulis3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ module.exports = {
aliases: ['n3'],
cooldown: 50,
description: 'Untuk menuliskan di buku bot\nPenggunaan !nulis3 _tulisan_',
execute (client, chat, pesan, args) {
execute (client: any, chat: any, pesan: any, args: any) {
const value = args.slice().join(' ')
fetchJson(`https://tools.zone-xsec.com/api/nulis.php?q=${value}`)
.then(async (hasil) => {
.then(async (hasil: any) => {
client.reply(pesan.tunggu)
const image = await getBuffer(hasil.image)
client.sendMessage(client.from, image, MessageType.image, { quoted: chat, caption: pesan.berhasil })
}).catch((err) => {
}).catch((err: string) => {
console.log(err)
client.log(err)
})
Expand Down
2 changes: 1 addition & 1 deletion src/command/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
name: 'ping',
cooldown: 10,
description: 'Menampilkan rata-rata bot merespon',
execute (client) {
execute (client: any) {
client.sendMessage(client.from, `Pong!!\n${processTime(client.pingStart, moment())} _detik_`, MessageType.text).catch(console.error)
}
}
2 changes: 1 addition & 1 deletion src/command/promote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
aliases: ['pm'],
cooldown: 10,
description: 'Untuk manjadikan admin anggota di group\nPenggunaan: !promote _quoted/tag_',
execute (client, chat, pesan) {
execute (client: any, chat: any, pesan: any) {
if (!client.isGroup) return client.reply(pesan.error.group)
if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin)
if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin)
Expand Down
2 changes: 1 addition & 1 deletion src/command/slap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
name: 'slap',
cooldown: 10,
description: 'Untuk menampol orang\nPenggunaan !slap _quoted/tag_',
execute (client, chat, pesan, args) {
execute (client: any, chat: any, pesan: any) {
if (!client.isGroup) return client.reply(pesan.error.group)
if (chat.message.extendedTextMessage === undefined || chat.message.extendedTextMessage === null) return client.reply('Tag target yang ingin di tonjok!')
const mentions = client.quotedId || client.mentioned
Expand Down
20 changes: 10 additions & 10 deletions src/command/sticker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
aliases: ['s', 'st'],
cooldown: 600,
description: 'Untuk menjadikan video atau gambar menjadi sticker\nPenggunaan: quoted gambar/vidio !sticker <rbg/nobg> rbg: remove background, nobg: no background on sticker, default sticker dengan background',
async execute (client, chat, pesan, args) {
async execute (client: any, chat: any, pesan: any, args: any) {
if ((client.isMedia && !chat.message.videoMessage || client.isQuotedImage) && args[0] == 'nobg') {
if ((!client.isGroup && !client.isPmium) || (client.isGroup && !client.isGmium)) return client.reply(pesan.hanya.premium)
const encmedia = client.isQuotedImage ? JSON.parse(JSON.stringify(chat).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : chat
Expand All @@ -21,10 +21,10 @@ module.exports = {
client.reply(pesan.tunggu)
await ffmpeg(`./${media}`)
.input(media)
.on('start', function (cmd) {
.on('start', function (cmd: string) {
console.log(`[INFO] Started : ${cmd}`)
})
.on('error', function (err) {
.on('error', function (err: string) {
console.log(`[INFO] Error : ${err}`)
fs.unlinkSync(media)
client.reply('Error saat membuat sticker')
Expand All @@ -47,10 +47,10 @@ module.exports = {
client.reply(pesan.tunggu)
await ffmpeg(`./${media}`)
.inputFormat(media.split('.')[1])
.on('start', function (cmd) {
.on('start', function (cmd: string) {
console.log(`[INFO] Started : ${cmd}`)
})
.on('error', function (err) {
.on('error', function (err: string) {
console.log(`[INFO] Error : ${err}`)
fs.unlinkSync(media)
const tipe = media.endsWith('.mp4') ? 'video' : 'gif'
Expand All @@ -74,13 +74,13 @@ module.exports = {
const ranp = getRandom('.png')
client.reply(pesan.tunggu)
const keyrmbg = process.env.KEY_REMOVEBG
await removeBackgroundFromImageFile({ path: media, apiKey: keyrmbg, size: 'auto', type: 'auto', ranp }).then(res => {
await removeBackgroundFromImageFile({ path: media, apiKey: keyrmbg, size: 'auto', type: 'auto', ranp }).then((res: any) => {
fs.unlinkSync(media)
const buffer = Buffer.from(res.base64img, 'base64')
fs.writeFileSync(ranp, buffer, (err) => {
fs.writeFileSync(ranp, buffer, (err: string) => {
if (err) return client.reply('Gagal, Terjadi kesalahan, silahkan coba beberapa saat lagi.')
})
exec(`ffmpeg -i ${ranp} -vcodec libwebp -filter:v fps=fps=20 -lossless 1 -loop 0 -preset default -an -vsync 0 -s 512:512 ${ranw}`, (err) => {
exec(`ffmpeg -i ${ranp} -vcodec libwebp -filter:v fps=fps=20 -lossless 1 -loop 0 -preset default -an -vsync 0 -s 512:512 ${ranw}`, (err: string) => {
fs.unlinkSync(ranp)
if (err) return client.reply('Error saat membuat sticker')
client.sendMessage(client.from, fs.readFileSync(ranw), MessageType.sticker, { quoted: chat })
Expand All @@ -91,10 +91,10 @@ module.exports = {
const media = await client.downloadAndSaveMediaMessage(encmedia)
const ranw = getRandom('.webp')
await ffmpeg(`./${media}`)
.on('start', function (cmd) {
.on('start', function (cmd: any) {
console.log('[INFO] Started :', cmd)
})
.on('error', function (err) {
.on('error', function (err: any) {
fs.unlinkSync(media)
console.log('[INFO] Error :', err)
client.reply('Error saat membuat sticker')
Expand Down
Loading

0 comments on commit 2788c97

Please sign in to comment.