如何使不和谐的机器人在一条消息中打印出关联数组的每个元素?

时间:2020-07-30 03:35:48

标签: javascript bots discord.js

在我的服务器上,我有一个这样的硬币系统:

coin = []

if(msg.content === !coin){
    coin[msg.author.discriminator] = 1 //i found this way to make an array with exclusive values for each user
    msg.reply('now you have a gold coin :)')
}

现在这是问题所在:我需要机器人在一条消息中向我发送数组的每个对象以创建数据库,并发送如下信息:

if(msg.content === '!usercoin'){

   msg.reply(coin[numbers != null]}



bot's reply: 1234:1 , 1235:1, 4444:1, 9999:1 //exemple that i need

1 个答案:

答案 0 :(得分:0)

您需要执行msg.reply(coin.join(", "))。另外,numbers尚未定义,coin不是持久性的,因此,您应使用enmapmongodb等数据库。Enmap的使用非常简单! Here is some examples

PS:如果您使用的是heroku,则不能使用任何数据库