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

176
Views
Handling [object Promise] from noblox.js in discord.js

Surprisingly difficult to find this on google...

So I'm making a discord bot with discord.js and connecting a noblox.js bot to it.

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);

Payout is commented because I do not want to yet, I am just trying to make messaging work.

Output on discord when I type the !payout command:

Paid 1 robux to [object Promise]

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

0

You have to await the getUser as it's an async function and returns a promise

const username = await getUser(args[2])

Note: you must change the messageCreate callback to asynchronous

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!