简体   繁体   English

JAVASCRIPT 如何让 API 使用命令后发出一个数字

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

How would I make this API for FIVEM我如何为 FIVEM 制作这个 API

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.将玩家的数量记录到我想要的命令中,例如 /stats 将使用 API 在命令运行时显示玩家。 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));
    }
});

try this.尝试这个。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不使用 jquery 但使用 javascript 的情况下使 ajax 每 (n) 秒更新一次? - How make ajax update every (n) number of seconds with out using jquery but using javascript? 如何仅使用 JavaScript 制作数字掩码? - How to make a number mask using only JavaScript? 如何使用JavaScript找出从xml检索的元素数量 - How to find out the number of elements retrieved from a xml using javascript 如何制作仅使用html和javascript发送电子邮件的表单 - How to make a form that would send emails using only html and javascript 如何使用 api_key 使 API 请求 javascript 代码? - How to make API request javascript code with using api_key? 尝试使用 JavaScript 客户端在 discord 中发送一个命令时出现 Discord API 错误 - Discord API error when trying to send one command at discord using JavaScript client 如何使用JavaScript进行幻灯片制作? - How Can I Make A Slide-Out Using Javascript? 如何使用javascript / jquery使屏幕外的表行不可见 - How to make unvisible the rows of table that out of screen using javascript / jquery 如何使用Gmail API和Javascript发送带有本地附件的电子邮件? - How to send emails with Local Attachments using Gmail API and Javascript? 如何使用 JavaScript 和 HTML 变量发送 API 获取请求 - How to send an API get request using JavaScript with HTML variables
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM