Logo OmniDevvKANA Web
Kembali ke katalog plugin

user

jam

Lihat jam sekarang di WIB, WITA, WIT, dan UTC

See the current time in WIB, WITA, WIT, and UTC

plugins/user/jam.js

Lokasi file di repo kana-md

2

Perintah termasuk alias

1.6 KB

Ukuran file sumber

4/11/2026

Update terakhir, commit 44f4010

Daftar perintah

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

.jam.waktu

Cara pakai

.jam

Contoh

.jam

Kode sumber plugin

Unduh .js

Cara pasang: simpan file ini ke folder plugins/user/ 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'

export const config = {
  name: 'jam',
  alias: ['waktu'],
  category: 'user',
  description: { id: 'Lihat jam sekarang di WIB, WITA, WIT, dan UTC', en: 'See the current time in WIB, WITA, WIT, and UTC' },
  usage: '.jam',
  example: '.jam',
  cooldown: 3,
}

export const i18n = {
  id: {
    jam: {
      title: 'Jam Sekarang 🕰️',
      body: 'Sekarang jam segini nih~\n🕰️ WIB (Jakarta): {wib}\n🕰️ WITA (Makassar): {wita}\n🕰️ WIT (Jayapura): {wit}\n🌍 UTC: {utc}\n\n{mood}',
      btnMenu: 'Menu User',
    },
  },
  en: {
    jam: {
      title: 'Current Time 🕰️',
      body: 'The time right now~\n🕰️ WIB (Jakarta): {wib}\n🕰️ WITA (Makassar): {wita}\n🕰️ WIT (Jayapura): {wit}\n🌍 UTC: {utc}\n\n{mood}',
      btnMenu: 'User Menu',
    },
  },
}

function clockIn(timeZone, date) {
  return new Intl.DateTimeFormat('en-GB', {
    timeZone,
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit',
    hour12: false,
  }).format(date)
}

export const test = { input: '.jam', expect: /WIB/i }

export async function handler(ctx) {
  const now = new Date()
  const body = ctx.t('jam.body', {
    wib: clockIn('Asia/Jakarta', now),
    wita: clockIn('Asia/Makassar', now),
    wit: clockIn('Asia/Jayapura', now),
    utc: clockIn('UTC', now),
    mood: ctx.say('senang'),
  })
  return sendButtons(ctx.sock, ctx.chat, {
    title: ctx.t('jam.title'),
    body,
    footer: ctx.t('menu.footer'),
    replies: [{ text: ctx.t('jam.btnMenu'), id: '.menu user' }],
    textFallback: body,
  })
}