Logo OmniDevvKANA Web
Kembali ke katalog plugin

fun

joke

Lelucon acak original dari KANA

A random original joke from KANA

plugins/fun/joke.js

Lokasi file di repo kana-md

3

Perintah termasuk alias

1.5 KB

Ukuran file sumber

4/11/2026

Update terakhir, commit 4be2f30

Daftar perintah

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

.joke.lucu.lelucon

Cara pakai

.joke

Contoh

.joke

Kode sumber plugin

Unduh .js

Cara pasang: simpan file ini ke folder plugins/fun/ 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 { JOKES } from '../../src/data/fun.js'

// Lelucon original dari dataset fun (src/data/fun.js). Ditambahkan koordinator
// saat integrasi karena dataset JOKES belum punya perintah yang menyajikan.
export const config = {
  name: 'joke',
  alias: ['lucu', 'lelucon'],
  category: 'fun',
  description: { id: 'Lelucon acak original dari KANA', en: 'A random original joke from KANA' },
  usage: '.joke',
  example: '.joke',
  cooldown: 3,
}

export const i18n = {
  id: {
    joke: {
      title: '😂 Lelucon KANA',
      btnAgain: '😂 Lagi Dong',
      btnTruth: '🫣 Truth',
      btnDare: '😈 Dare',
    },
  },
  en: {
    joke: {
      title: '😂 KANA Joke',
      btnAgain: '😂 One More',
      btnTruth: '🫣 Truth',
      btnDare: '😈 Dare',
    },
  },
}

export function pickJoke(lang, rng = Math.random) {
  const item = JOKES[Math.floor(rng() * JOKES.length)]
  return item[lang] ?? item.id
}

export const test = { input: '.joke', expect: /lelucon|joke/i }

export async function handler(ctx) {
  const body = `${ctx.t('joke.title')}\n\n${pickJoke(ctx.lang)}\n\n${ctx.say('senang')}`
  return sendButtons(ctx.sock, ctx.chat, {
    title: 'KANA',
    body,
    footer: ctx.t('menu.footer'),
    replies: [
      { text: ctx.t('joke.btnAgain'), id: '.joke' },
      { text: ctx.t('joke.btnTruth'), id: '.truth' },
      { text: ctx.t('joke.btnDare'), id: '.dare' },
    ],
    textFallback: body,
  })
}