【问题标题】:Is it possible to store some guild id in a set in discord?是否可以在不和谐的集合中存储一些公会 ID?
【发布时间】:2019-11-05 15:48:41
【问题描述】:
我想将一些公会 ID 存储到我的机器人中。我使用了Set(),但它没有用,因为当我的机器人离线时,我的集合中的所有 id 都会被删除,所以我需要一次又一次地添加它们。有什么解决办法吗?
我试过这个:
const collection = new Set();
if (message.content.startsWith(!verify)) {
collection.add(message.guild.id)
return message.channel.send("Server Verified");
}
【问题讨论】:
标签:
javascript
node.js
set
discord
discord.js
【解决方案1】:
是的,我同意 Francois S 的观点。这就是您使用 Quick.DB 的方式 (npm i quick.db)
const db = require("quick.db");
if (message.content.startsWith(!verify)) {
db.set(`${message.guild.id}-verify`, true);
return message.channel.send("Server Verified");
}
然后在另一个命令中你可以检查它是否等于 true:
const db = require("quick.db");
let verifyTrue = db.fetch(`${message.guild.id}-verify`)
if(verifyTrue == true) {
blah blah blah
}