-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,10 @@ const { | |
const { Collection } = require('discord.js') | ||
const { readdirSync } = require('fs') | ||
const { join } = require('path') | ||
const { start, success } = require('./utils/functions') | ||
const { start, success, getGroupAdmins } = require('./utils/functions') | ||
const { color } = require('./utils/color') | ||
const fs = require('fs') | ||
const moment = require('moment-timezone') | ||
|
||
async function krypton () { | ||
const client = new WAConnection() | ||
|
@@ -36,7 +37,7 @@ async function krypton () { | |
// Server connected | ||
await client.on('open', () => { | ||
success('1', '[SERVER] Terhubung') | ||
console.log('🤖',color('KryPtoN Bot Sudah siap!!', 'green')) | ||
console.log('🤖', color('KryPtoN Bot Sudah siap!!', 'green')) | ||
}) | ||
|
||
// Create file for sessions | ||
|
@@ -51,12 +52,53 @@ async function krypton () { | |
if (!chat.message) return | ||
if (chat.key.remoteJid == 'status@broadcast') return | ||
if (chat.key.fromMe) return | ||
|
||
// Variable | ||
const from = chat.key.remoteJid | ||
const type = Object.keys(chat.message)[0] | ||
body = (type === 'conversation' && chat.message.conversation.startsWith(prefix)) ? chat.message.conversation : (type == 'imageMessage') && chat.message.imageMessage.caption.startsWith(prefix) ? chat.message.imageMessage.caption : (type == 'videoMessage') && chat.message.videoMessage.caption.startsWith(prefix) ? chat.message.videoMessage.caption : (type == 'extendedTextMessage') && chat.message.extendedTextMessage.text.startsWith(prefix) ? chat.message.extendedTextMessage.text : '' | ||
const args = body.trim().split(/ +/).slice(1) | ||
const isCmd = body.startsWith(prefix) | ||
const commandName = body.slice(1).trim().split(/ +/).shift().toLowerCase() | ||
const time = moment.tz('Asia/Jakarta').format('DD/MM HH:mm:ss') | ||
const content = JSON.stringify(chat.message) | ||
|
||
const botNumber = client.user.jid | ||
const ownerNumber = ["[email protected]"] // replace this with your number | ||
const isGroup = from.endsWith('@g.us') | ||
const sender = isGroup ? chat.participant : chat.key.remoteJid | ||
const groupMetadata = isGroup ? await client.groupMetadata(from) : '' | ||
const groupName = isGroup ? groupMetadata.subject : '' | ||
const groupId = isGroup ? groupMetadata.jid : '' | ||
const groupMembers = isGroup ? groupMetadata.participants : '' | ||
const groupAdmins = isGroup ? getGroupAdmins(groupMembers) : '' | ||
const isBotGroupAdmins = groupAdmins.includes(botNumber) || false | ||
const isGroupAdmins = groupAdmins.includes(sender) || false | ||
const isOwner = ownerNumber.includes(sender) | ||
const isUrl = (url) => { | ||
return url.match(new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/, 'gi')) | ||
} | ||
const reply = (teks) => { | ||
client.sendMessage(from, teks, text, {quoted:chat}) | ||
} | ||
const sendMess = (hehe, teks) => { | ||
client.sendMessage(hehe, teks, text) | ||
} | ||
const mentions = (teks, memberr, id) => { | ||
(id == null || id == undefined || id == false) ? client.sendMessage(from, teks.trim(), extendedText, {contextInfo: {"mentionedJid": memberr}}) : client.sendMessage(from, teks.trim(), extendedText, {quoted: chat, contextInfo: {"mentionedJid": memberr}}) | ||
} | ||
|
||
colors = ['red','white','black','blue','yellow','green'] | ||
const isMedia = (type === 'imageMessage' || type === 'videoMessage') | ||
const isQuotedImage = type === 'extendedTextMessage' && content.includes('imageMessage') | ||
const isQuotedVideo = type === 'extendedTextMessage' && content.includes('videoMessage') | ||
const isQuotedSticker = type === 'extendedTextMessage' && content.includes('stickerMessage') | ||
|
||
// Logging Message | ||
if (!isGroup && isCmd) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;32mEXEC\x1b[1;37m]', time, color(commandName), 'from', color(sender.split('@')[0]), 'args :', color(args.length)) | ||
if (!isGroup && !isCmd) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;31mRECV\x1b[1;37m]', time, color('Message'), 'from', color(sender.split('@')[0]), 'args :', color(args.length)) | ||
if (isCmd && isGroup) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;32mEXEC\x1b[1;37m]', time, color(commandName), 'from', color(sender.split('@')[0]), 'in', color(groupName), 'args :', color(args.length)) | ||
if (!isCmd && isGroup) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;31mRECV\x1b[1;37m]', time, color('Message'), 'from', color(sender.split('@')[0]), 'in', color(groupName), 'args :', color(args.length)) | ||
|
||
/** | ||
* Import all commands | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters