Logo OmniDevvKANA Web
Kembali ke katalog plugin

owner

ban

Ban satu nomor dari memakai bot

Ban one number from using the bot

plugins/owner/ban.js

Lokasi file di repo kana-md

1

Perintah termasuk alias

1.8 KB

Ukuran file sumber

4/11/2026

Update terakhir, commit a0f6049

Daftar perintah

Ketuk tombol salin untuk menyalin perintah, lalu tempel di chat WhatsApp bot KANA.

.ban

Cara pakai

.ban <nomor>

Contoh

.ban 6281234567890

Kode sumber plugin

Unduh .js

Cara pasang: simpan file ini ke folder plugins/owner/ di bot KANA kamu, lalu restart bot. Pemilik source code lain bisa mengambil update plugin terbaru dari halaman ini kapan saja.

import { sendButtons } from '../../src/ui/buttons.js'
import { updateProfile } from '../../src/services/user-service.js'

export const config = {
  name: 'ban',
  alias: [],
  category: 'owner',
  description: { id: 'Ban satu nomor dari memakai bot', en: 'Ban one number from using the bot' },
  usage: '.ban <nomor>',
  example: '.ban 6281234567890',
  cooldown: 3,
  isOwner: true,
}

export const i18n = {
  id: {
    ban: {
      hint: 'Sebutin nomornya dulu yaa, Master. Contoh: .ban 6281234567890, atau mention orangnya~',
      done: 'Siap, Master~ nomor {number} udah KANA ban. {mood}',
      btnUnban: 'Cabut Ban',
      btnOwner: 'Status Bot',
    },
  },
  en: {
    ban: {
      hint: 'Give the number first, Master. Example: .ban 6281234567890, or mention the person~',
      done: 'Got it, Master~ number {number} is banned. {mood}',
      btnUnban: 'Lift Ban',
      btnOwner: 'Bot Status',
    },
  },
}

function targetDigits(ctx) {
  if (ctx.mentionedJids?.length) {
    const d = String(ctx.mentionedJids[0]).replace(/\D/g, '')
    if (d.length >= 9 && d.length <= 15) return d
  }
  const d = (ctx.text || '').replace(/\D/g, '')
  return d.length >= 9 && d.length <= 15 ? d : ''
}

export const test = { input: '.ban', expect: /nomor/i }

export async function handler(ctx) {
  const digits = targetDigits(ctx)
  if (!digits) return ctx.reply(ctx.t('ban.hint'))
  await updateProfile(ctx.storage, digits, { banned: true })
  const body = ctx.t('ban.done', { number: digits, mood: ctx.say('sukses') })
  return sendButtons(ctx.sock, ctx.chat, {
    title: 'KANA',
    body,
    footer: ctx.t('menu.footer'),
    replies: [
      { text: ctx.t('ban.btnUnban'), id: `.unban ${digits}` },
      { text: ctx.t('ban.btnOwner'), id: '.owner' },
    ],
    textFallback: body,
  })
}