Logo OmniDevvKANA Web
Kembali ke katalog plugin

rpg

shop

Lihat barang yang dijual toko RPG dan harganya

See what the RPG shop sells and its prices

plugins/rpg/shop.js

Lokasi file di repo kana-md

2

Perintah termasuk alias

2.1 KB

Ukuran file sumber

4/11/2026

Update terakhir, commit eae5127

Daftar perintah

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

.shop.toko

Cara pakai

.shop

Contoh

.shop

Kode sumber plugin

Unduh .js

Cara pasang: simpan file ini ke folder plugins/rpg/ 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 { SHOP, ITEM_MAP } from '../../src/rpg/data.js'
import { getProfile } from '../../src/services/user-service.js'

export const config = {
  name: 'shop',
  alias: ['toko'],
  category: 'rpg',
  description: { id: 'Lihat barang yang dijual toko RPG dan harganya', en: 'See what the RPG shop sells and its prices' },
  usage: '.shop',
  example: '.shop',
  cooldown: 3,
}

export const i18n = {
  id: {
    shop: {
      body: '🛒 TOKO KANA 🛒\nKoin kamu: {coins} 💰\n\n{list}\n\nBeli: .buy <item> [jumlah]\nJual: .buy jual <item> [jumlah] (harga jual ada di .inventory)',
      line: '{emoji} {name} ({id}): {price} koin',
      btnInventory: 'Tas Aku',
      btnCraft: 'Craft',
      btnProfile: 'Profil RPG',
    },
  },
  en: {
    shop: {
      body: '🛒 KANA SHOP 🛒\nYour coins: {coins} 💰\n\n{list}\n\nBuy: .buy <item> [qty]\nSell: .buy jual <item> [qty] (sell prices are in .inventory)',
      line: '{emoji} {name} ({id}): {price} coins',
      btnInventory: 'My Bag',
      btnCraft: 'Craft',
      btnProfile: 'RPG Profile',
    },
  },
}

export const test = { input: '.shop', expect: /toko/i }

export async function handler(ctx) {
  const profile = await getProfile(ctx.storage, ctx.senderDigits)
  const list = SHOP.map((s) => {
    const item = ITEM_MAP[s.id]
    return ctx.t('shop.line', { emoji: item?.emoji ?? '❔', name: item ? item.name[ctx.lang] ?? item.name.id : s.id, id: s.id, price: s.price })
  }).join('\n')
  const body = ctx.t('shop.body', { coins: profile.balance ?? 0, list })
  const replies = [
    ...SHOP.slice(0, 5).map((s) => {
      const item = ITEM_MAP[s.id]
      return { text: `${item?.emoji ?? ''} ${(item ? item.name[ctx.lang] ?? item.name.id : s.id)}`.slice(0, 25), id: `.buy ${s.id}` }
    }),
    { text: ctx.t('shop.btnInventory'), id: '.inventory' },
    { text: ctx.t('shop.btnCraft'), id: '.craft' },
    { text: ctx.t('shop.btnProfile'), id: '.rpg' },
  ]
  return sendButtons(ctx.sock, ctx.chat, { title: 'KANA RPG', body, footer: ctx.t('menu.footer'), replies, textFallback: body })
}