Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
Manejo de [promesa de objeto] de noblox.js en discord.js

Sorprendentemente difícil de encontrar esto en google...

Así que estoy haciendo un bot discord con discord.js y conectándolo con un bot noblox.js.

 const nbx = require('noblox.js'); const { Client, Intents } = require('discord.js'); const { token } = require('./config.json'); const prefix = '!'; const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES ] }) async function payout(userId, amount) { await nbx.setCookie('roblox cookie'); nbx.groupPayout(12845526, userId, amount, false); console.log("paid " + amount + " robux to " + userId) } async function getUser(userId) { let username = await nbx.getUsernameFromId(userId); return username; } client.on("ready", () => { console.log("Bot is ready"); }); client.on("messageCreate", (message) => { if (!message.content.startsWith(prefix)) return; const args = message.content.trim().split(/ +/g); const cmd = args[0].slice(prefix.length).toLowerCase(); // case INsensitive, without prefix if (cmd === 'test') message.reply('Bot is online!'); if (cmd === 'payout') { if (!args[3]) return message.reply('Correct usage: Group, Player, Amount'); const username = getUser(args[2]); message.reply('Paid ' + args[3] + " robux to " + username); //payout(userId, amount); } }); client.login(token);

El pago se comenta porque no quiero hacerlo todavía, solo estoy tratando de hacer que la mensajería funcione.

Salida en discordia cuando escribo el comando !payout:

Pagó 1 robux a [object Promise]

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe await el getUser ya que es una función asíncrona y devuelve una promesa

 const username = await getUser(args[2])

Nota: debe cambiar el mensaje messageCreate devolución de llamada a asíncrono

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!