Skip to content

Commit

Permalink
fix setmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
Nurutomo committed Jan 15, 2021
1 parent c0d4e47 commit d0e1901
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 40 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ conn.handler = async function (m) {
let isPrems = isMods || global.prems.includes(m.sender)
let groupMetadata = m.isGroup ? await this.groupMetadata(m.chat) : {}
let participants = m.isGroup ? groupMetadata.participants : []
let user = m.isGroup ? participants.filter(u => u.jid == m.sender)[0] : {}
let bot = m.isGroup ? participants.filter(u => u.jid == this.user.jid)[0] : {}
let user = m.isGroup ? participants.find(u => u.jid == m.sender) : {}
let bot = m.isGroup ? participants.find(u => u.jid == this.user.jid) : {}
let isAdmin = user.isAdmin || user.isSuperAdmin || false
let isBotAdmin = bot.isAdmin || bot.isSuperAdmin || false
if (plugin.before) plugin.before({
Expand Down
39 changes: 10 additions & 29 deletions plugins/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ let handler = async (m, { conn, usedPrefix: _p }) => {
let name = conn.getName(m.sender)
let d = new Date
let locale = 'id'
let weton = ['Pon','Wage','Kliwon','Legi','Pahing'][Math.floor(d / 84600000) % 5]
let gmt = new Date(0) - new Date('1 January 1970')
let weton = ['Pon','Wage','Kliwon','Legi','Pahing'][Math.floor((d + gmt) / 84600000) % 5]
let week = d.toLocaleDateString(locale, { weekday: 'long' })
let date = d.toLocaleDateString(locale, {
day: 'numeric',
Expand All @@ -17,8 +18,8 @@ let handler = async (m, { conn, usedPrefix: _p }) => {
minute: 'numeric',
second: 'numeric'
})
let _uptime = new Date(new Date - global.timestamp.start)
let uptime = ['getHours','getMinutes','getSeconds'].map(method => _uptime[method]().toString().padStart(2, 0)).join`:`
let _uptime = new Date(process.uptime() * 1000)
let uptime = clockString(_uptime)
let tags = {
'main': 'Main',
'xp': 'Exp & Limit',
Expand Down Expand Up @@ -56,7 +57,7 @@ let handler = async (m, { conn, usedPrefix: _p }) => {
if (menu.help) groups[tag].push(menu)
}
conn.menu = conn.menu ? conn.menu : {}
let before = conn.menu.before || `${conn.getName(conn.user.jid)} • Bot\n\nHai, %name!\n*%exp XP*\n*%limit Limit*\n*%week %weton, %date*\n*%time*\n%readmore`
let before = conn.menu.before || `${conn.getName(conn.user.jid)} • Bot\n\nHai, %name!\n*%exp XP*\n*%limit Limit*\n*%week %weton, %date*\n*%time*\n_Uptime: %uptime\n%readmore`
let header = conn.menu.header || '╭─「 %category 」'
let body = conn.menu.body || '│ • %cmd%islimit'
let footer = conn.menu.footer || '╰────\n'
Expand All @@ -70,10 +71,11 @@ let handler = async (m, { conn, usedPrefix: _p }) => {
}
_text += footer + '\n'
}
_text += after
text = typeof conn.menu == 'string' ? conn.menu : typeof conn.menu == 'object' ? _text : ''
let replace = {
'%': '%',
p: _p,
p: _p, uptime: _uptime
exp, limit, name, weton, week, date, time,
readmore: readMore
}
Expand Down Expand Up @@ -102,28 +104,7 @@ module.exports = handler

const more = String.fromCharCode(8206)
const readMore = more.repeat(4001)
/* ╭─「 𝗠𝗲𝗱𝗶𝗮 𝗖𝗼𝗺𝗺𝗮𝗻𝗱𝘀 」
│ • #memes │ • #asupan ⚡
│ • #ajg
│ • #bcl │ • #koceng
│ • #pokemon ╰────
╭─「 𝗪𝗶𝗯𝘂 𝗖𝗼𝗺𝗺𝗮𝗻𝗱𝘀 」 │ • #loli
│ • #shota ⚡ │ • #waifu
│ • #hentai ⚡
│ • #husbu │ • #nekoNime ⚡
│ • #randomBlowjob ⚡
│ • #randomCry ⚡
│ • #randomHug ⚡ │ • #randomKiss ⚡
│ • #malAnime
│ • #malCharacter
│ • #whatAnime
╰────
╭─「 𝗜𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝗺𝗺𝗮𝗻𝗱𝘀 」
│ • #infoGempa │ • #cuaca │ • #covidIndo
│ • #checkIP ⚡
╰────
╭─「 𝗢𝘁𝗵𝗲𝗿 𝗖𝗼𝗺𝗺𝗮𝗻𝗱𝘀 」 │ • #artiNama
│ • #artiMimpi ⚡ │ • #artiZodiak ⚡ │ • #ramalPasangan │ • #nomorHoki)
*/

function clockString(date) {
return ['getHours','getMinutes','getSeconds'].map(method => date[method]().toString().padStart(2, 0)).join`:`
}
40 changes: 31 additions & 9 deletions plugins/setmenu.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
let handler = async (m, { conn, text }) => {
if (args.length > 0) {
conn.menu = text
conn.reply(m.chat, 'Menu berhasil diatur\n' + info, m)
let handler = async (m, { conn, usedPrefix, text }) => {
let type = usedPrefix.replace(/^set(menu|help|\?)/, '').toLowerCase()
if (type == '') {
if (text) {
conn.menu = text
conn.reply(m.chat, 'Menu berhasil diatur\n' + info, m)
} else {
conn.menu = {}
conn.reply(m.chat, 'Menu direset', m)
}
} else {
conn.menu = ''
delete conn.menu
conn.reply(m.chat, 'Menu direset', m)
conn.menu = typeof conn.menu == 'object' ? conn.menu : {}
if (text) {
conn.menu[type] = text
conn.reply(m.chat, 'Menu ' + type + ' berhasil diatur\n' + info, m)
} else {
delete conn.menu[type]
conn.reply(m.chat, 'Menu ' + type + ' direset', m)
}
}
}
handler.help = ['setmenu'].map(v => v + ' <teks>')
handler.help = ['', 'before','header','body','footer','after'].map(v => 'setmenu' + v + ' <teks>')
handler.tags = ['owner']
handler.command = /^set(menu|help|\?)$/i
handler.command = /^set(menu|help|\?)(before|header|body|footer|after)?$/i
handler.owner = true
handler.mods = false
handler.premium = false
Expand All @@ -25,11 +36,22 @@ handler.fail = null
module.exports = handler

let info = `
Universal:
%% (%)
%p (Prefix)
%exp (Exp)
%limit (Limit)
%name (Nama)
%weton (Weton Hari ini)
%week (Hari)
%date (Tanggal)
%time (Jam)
%uptime (Uptime Bot)
Bagian Menu Header & Footer:
%category (Kategori)
Bagian Menu Body:
%cmd (Command)
%isLimit (Jika command di limit)
`.trim()

0 comments on commit d0e1901

Please sign in to comment.