A

e devi usare node.js

📎 1 file 1,575 chars
📄
pasted-code-1788893609526.txt
txt 40 lines
▶
🤖 AETERNUM ROLEPLAY — SPECIFICA BOT 1/2

💰 ECONOMIA

1. "/crea-conto" — Crea conto, PIN 4 cifre sicuro e saldo iniziale.
2. "/conto" — Mostra saldo, stato e proprietario.
3. "/deposita" — Deposita contanti.
4. "/ritira" — Prelievo con importo + PIN.
5. "/paga" — Pagamento tra giocatori.
6. "/bonifico" — ATM con tastierino, PIN, destinatario, importo e conferma.
7. "/give-soldi" — Staff dà denaro.
8. "/rimuovi-soldi" — Staff rimuove denaro.
9. "/set-soldi" — Staff imposta saldo.
10. "/set-soldi-nuovi" — Imposta denaro iniziale.

🏢 AZIENDE
11. "/crea-conto-aziendale" — Crea conto aziendale.
12. "/conto-aziendale" — Mostra dati azienda.
13. "/deposita-azienda" — Deposita nel conto.
14. "/ritira-azienda" — Prelievo con controlli.
15. "/paga-azienda" — Pagamento a giocatore/altra azienda.

🎒 INVENTARIO & ITEM
16. "/inventario" — Mostra oggetti posseduti.
17. "/crea-item" — Staff crea item con nome, emoji, tipo, descrizione, effetto e prezzo.
18. "/elimina-item" — Elimina item.
19. "/give-item" — Staff dà item.
20. "/rimuovi-item" — Staff rimuove item.
21. "/rovista" — Controllo altro giocatore con cooldown.

🏪 NEGOZIO
22. "/negozio" — Mostra prodotti, prezzi, disponibilità e descrizioni.
23. "/acquista" — Controlla denaro/disponibilità e aggiunge item.

🍔 FAME & SETE
24. "/fame" — Fame 0–100.
25. "/sete" — Sete 0–100.
26. "/mangia" — Mostra solo cibi posseduti, consuma 1 e aumenta fame.
27. "/bevi" — Mostra solo bevande possedute, consuma 1 e aumenta sete.
⏱️ Fame/sete diminuiscono automaticamente con valori configurabili e avvisi ai livelli bassi.
Kodari AI
KodariSep 8 at 7:00 pm 2
RoleplayEconomyBot
A comprehensive Discord roleplay economy bot for Minecraft servers. Features include player and company bank accounts with secure PIN authentication, deposits, withdrawals, transfers, and staff administrative commands. Includes an item system with custom items, inventories, and player searches. A shop system allows purchasing items with currency. Hunger and thirst mechanics track player vitals with configurable decay rates and low-level warnings. All commands are slash-command based with role-based permissions for staff operations.

Piano:

  1. Creare la base Node.js con Discord.js, SQLite e configurazione tramite .env.

  2. Implementare database e servizi per conti, aziende, inventario, negozio e bisogni.

  3. Registrare tutti i comandi slash, inclusa conferma interattiva per /bonifico.

  4. Aggiungere decadimento automatico di fame/sete e avvisi configurabili.

Creato il bot Node.js per Aeternum Roleplay con:

  • Discord.js 14 e comandi slash

  • Database SQLite persistente

  • Conti personali con PIN cifrato

  • Depositi, prelievi, pagamenti e bonifici con conferma

  • Conti aziendali

  • Gestione staff di soldi e item

  • Inventari personali

  • Negozio con acquisto prodotti

  • Cibo, bevande, fame e sete

  • Decadimento automatico configurabile

  • Avvisi DM per fame/sete basse

  • Cooldown per /rovista

  • Configurazione tramite .env

File principali creati:

  • package.json

  • .env.example

  • src/index.js

  • src/config.js

  • src/security.js

  • src/db.js

  • src/commands.js

Avvio:

Shell
cp .env.example .env
npm install
npm start

Compila nel .env:

Env
DISCORD_TOKEN=token_del_bot
DISCORD_CLIENT_ID=id_applicazione
DEV_GUILD_ID=id_server_di_test

I comandi riservati allo staff richiedono il permesso Discord Gestisci server.

Kodari can make mistakes. Review important code before using.
Files
src
package.json
Code
6 659
src/index.js
const { Client, GatewayIntentBits, REST, Routes } = require('discord.js');
const config = require('./config');
const AeternumDatabase = require('./db');
const { commands, handleInteraction } = require('./commands');

if (!config.token || !config.clientId) {
  throw new Error('DISCORD_TOKEN e DISCORD_CLIENT_ID sono obbligatori nel file .env.');
}

const db = new AeternumDatabase(config.databasePath);
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

async function registerCommands() {
  const rest = new REST({ version: '10' }).setToken(config.token);
  const route = config.devGuildId
    ? Routes.applicationGuildCommands(config.clientId, config.devGuildId)
    : Routes.applicationCommands(config.clientId);
  await rest.put(route, { body: commands });
  console.log(`Registrati ${commands.length} comandi slash.`);
}

client.once('ready', () => {
  console.log(`Connesso come ${client.user.tag}.`);
  setInterval(() => {
    for (const id of db.getAllUserIds()) {
      const before = db.getUser(id);
      const after = db.applyNeeds(id, config.hungerDecayMinutes, config.hungerDecayAmount);
      if (!after || !before) continue;
      const low = after.hunger <= config.lowNeedThreshold || after.thirst <= config.lowNeedThreshold;
      if (low && Date.now() - after.last_low_warning_at >= config.lowNeedWarningMinutes * 60 * 1000) {
        db.setLowWarningTime(id, Date.now());
        const user = client.users.cache.get(id);
        if (user) user.send(`⚠️ Attenzione: i tuoi bisogni sono bassi. Fame: ${after.hunger}/100, sete: ${after.thirst}/100.`).catch(() => {});
      }
    }
  }, 60_000);
});

client.on('interactionCreate', interaction => {
  handleInteraction(interaction, db, config).catch(error => {
    console.error(error);
    const response = { content: 'Si è verificato un errore durante l operazione.', ephemeral: true };
    if (interaction.replied || interaction.deferred) interaction.followUp(response).catch(() => {});
    else interaction.reply(response).catch(() => {});
  });
});

registerCommands()
  .then(() => client.login(config.token))
  .catch(error => {
    console.error('Registrazione comandi fallita:', error);
    db.close();
    process.exitCode = 1;
  });

process.on('SIGINT', () => {
  db.close();
  client.destroy();
  process.exit(0);
});