【发布时间】:2021-05-21 13:55:20
【问题描述】:
所以,我的命令如下所示: +coords SpawnObject( "Truck_01_Covered_Blue", "6642.018555 461.256714 15280.805664", "-163.117828 -4.038700 1.684388" );我的代码是这样的:
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 === 'ping'){
message.channel.send('wing!');
} else if (command === 'coords') {
var [SpawnObject, BuildingName, pos, yaw] = args; {
var cords = pos.split(" ")
var a = yaw.split(" ")
var x = cords[0]
var y = cords[1]
var z = cords[2]
var a = a[0]
var b = (a+90) - 360 * Math.floor((a+90)/360)
console.log(`${`<pos x=${x}" y="${y}" z="${z}" a="${b}" />`}`);
}
}
});
然后我得到这样的结果:
pos x="6642.018555" y="undefined" z="undefined" a="101.25671490000002" /
它会读取第一个数字并放置它,然后它不会读取其他数字,我不知道它从哪里得到 a="101.25671490000002"。
【问题讨论】:
标签: node.js discord.js