gamedig玩家名单不和谐?

时间:2020-03-27 14:09:25

标签: javascript node.js discord.js

我想在这个DiscordJS中将所有玩家的名字都放在列表中吗? gamedig

client.on('message',async message => {
let args = message.content.split(' ');
if(args[0].toLowerCase() == `${prefix}mta`) {
Gamedig.query({type: 'mtasa',host: '45.88.108.110'}).then((state) => {
let emb = new Discord.RichEmbed()
.setTitle(`ServerIP: \`${state.connect}\``)
.addField("❯ Players",`» \`${state.players.length}\` \ / \`${state.maxplayers}\``,true)
.addField("❯ Players name",`» \`${state.players.names}\``,true)
.setColor("GRAY")
.setTimestamp()
.setFooter(client.user.username,client.user.avatarURL)
console.log(state);
message.channel.send(emb)
})
}
})

这是我服务器的数据,只想提供帮助

{ name:
   '[4Sky] Roleplay Server|فورسكاي للحياة الواقعية ولعب الادوار',
  map: 'Los Santos',
  password: false,
  raw:
   { gamename: 'mta',
     gametype: 'Los Santos V3.1',
     version: '1.5',
     numplayers: 47,
     'Script Version': '3.1',
     Author: '4Sky',
     Website: 'N/A' },
  maxplayers: 1024,
  players:
   [ { name: 'Marwan_O.Black',
       team: '',
       skin: '',
       score: 38,
       ping: 84,
       time: NaN },
     { name: 'pablo_D.Rew',
       team: '',
       skin: '',
       score: 6,
       ping: 107,
       time: NaN } ],
bots: [],
connect: '45.88.108.110:22003',
ping: 111 }

我想在这个DiscordJS中将所有玩家的名字都放在列表中吗? Gamedig 当我使用命令类型undefined或object object或什么都没有

1 个答案:

答案 0 :(得分:1)

使用此:

[]

它将创建一个名称数组,然后在嵌入中使用它。