Logo OmniDevvKANA Web
Kembali ke katalog plugin

rpg

recipes

Daftar lengkap resep craft dan bahannya

Full list of crafting recipes and their materials

plugins/rpg/recipes.js

Lokasi file di repo kana-md

1

Perintah termasuk alias

2.0 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.

.recipes

Cara pakai

.recipes

Contoh

.recipes

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 { RECIPES, ITEM_MAP } from '../../src/rpg/data.js'

export const config = {
  name: 'recipes',
  alias: [],
  category: 'rpg',
  description: { id: 'Daftar lengkap resep craft dan bahannya', en: 'Full list of crafting recipes and their materials' },
  usage: '.recipes',
  example: '.recipes',
  cooldown: 3,
}

export const i18n = {
  id: {
    recipes: {
      body: '📖 BUKU RESEP KANA 📖\n\n{list}\n\nKetik .craft <id> buat bikin yaa~',
      line: '{emoji} {name} (.craft {id})\n   Bahan: {needs}\n   Hasil: {gives}',
      btnCraft: 'Mulai Craft',
      btnInventory: 'Tas Aku',
      btnShop: 'Toko',
    },
  },
  en: {
    recipes: {
      body: '📖 KANA RECIPE BOOK 📖\n\n{list}\n\nType .craft <id> to make one~',
      line: '{emoji} {name} (.craft {id})\n   Needs: {needs}\n   Gives: {gives}',
      btnCraft: 'Start Crafting',
      btnInventory: 'My Bag',
      btnShop: 'Shop',
    },
  },
}

function fmtMap(ctx, map) {
  return Object.entries(map)
    .map(([id, qty]) => {
      const item = ITEM_MAP[id]
      return `${item?.emoji ?? ''} ${item ? item.name[ctx.lang] ?? item.name.id : id} x${qty}`
    })
    .join(', ')
}

export const test = { input: '.recipes', expect: /resep/i }

export async function handler(ctx) {
  const list = RECIPES.map((r) => {
    const givesId = Object.keys(r.gives)[0]
    return ctx.t('recipes.line', {
      emoji: ITEM_MAP[givesId]?.emoji ?? '🔨',
      name: r.name[ctx.lang] ?? r.name.id,
      id: r.id,
      needs: fmtMap(ctx, r.needs),
      gives: fmtMap(ctx, r.gives),
    })
  }).join('\n\n')
  const body = ctx.t('recipes.body', { list })
  return sendButtons(ctx.sock, ctx.chat, {
    title: 'KANA RPG',
    body,
    footer: ctx.t('menu.footer'),
    replies: [
      { text: ctx.t('recipes.btnCraft'), id: '.craft' },
      { text: ctx.t('recipes.btnInventory'), id: '.inventory' },
      { text: ctx.t('recipes.btnShop'), id: '.shop' },
    ],
    textFallback: body,
  })
}