DanThePvpGod
DanThePvpGod

Reputation: 31

JAVASCRIPT How to make API send out a number after using a command

How would I make this API for FIVEM

srv.getPlayers().then(data => console.log(data))

log the players' amount to the command I want for example /stats would use that API to show the players when the command is running. sorry if it's a dumb question.

this is what I came up with

client.on('message', message => {
    if(!message.content.startsWith(prefix) || message.author.bot) return;
    const args = message.content.slice(prefix.length).split(/ +/);
    const command = args.shift().toLowerCase();

    if(command === 'stats') {
       message.channel.send(srv.getPlayers().then(data));
    }
});

Upvotes: 1

Views: 86

Answers (1)

Vivek Jain
Vivek Jain

Reputation: 2864

try this.

srv.getPlayers().then(data => message.channel.send(data));

Upvotes: 2

Related Questions