当我们决定制作一个游戏板时,我正在和我的朋友一起编写一个 discordjs 机器人。基本上,它是一个频道,其中每条消息都会收到 2 :video_game: 反应被放在那里(比如“最佳消息”)。但是,有一个问题,我似乎无法解决它。这是我的代码:
client.on('messageReactionAdd', (reaction, user) => {
if (user.bot) return;
console.log(reaction);
if (reaction.emoji.name == '') {
if (reaction.count == 2) {
if (db.has('gameboard') == false) {
gameboard = db.table('gameboard');
};
if (db.get('gameboard', {id: reaction.author.id}) == null) {
db.add('gameboard', {
id: reaction.message.author.id,
username: reaction.message.author.username,
avatar: reaction.message.author.avatar,
content: reaction.message.content
});
}
msg = db.get('gameboard', {id: reaction.author.id});
embed = new Discord.MessageEmbed()
.setColor('RANDOM')
.setDescription(message.content)
.setAuthor(message.username, `https://cdn.discordapp.com/avatars/${msg.id}/${msg.author}.png?size=128`)
client.channels.cache.get('813807201042169926').send(embed);
};
};
});
我已经使用 json.sqlite 文件设置了 QuickDB。整个代码在这里是开源的。