我想做一个f炸弹计数器。因此,我查看了关于squelize和dbs的discordjs.guide,老实说,它很烦人,因为它的行为好像我已经知道它要教的一切。对我来说,它缺少很多技巧(我很容易被很多事情弄糊涂)。我想要做的是拥有一个像这样的数据库:
host: 'localhost',
dialect: 'sqlite',
logging: false,
storage: 'database.sqlite',
});
const Tags = sequelize.define('f_bombs', {
chatnname: {
type: Sequelize.STRING,
unique: true,
},
fbomb_count: {
type: Sequelize.INTEGER,
defaultValue: 0,
allowNull: false,
}, //<- basically a db that holds an f_bomb count for each chat the bot is in
//and then having something like this code below that interacts with the db I made, or somewhat made
bot.on('message', message=>{
if(message.content.includes('fart')) {
f_bombs[message.guild.id]++; //f_bombs
}
}
});
但是,我不知道如何为每个使用该bot的不和谐服务器存储一个变量(保存f炸弹计数),而每次关闭该bot时,该服务器都不会重新启动(这就是为什么我想使用一个数据库)。如果你们中有人找到除discordjs.guide以外的网站可以帮助我,将不胜感激!
答案 0 :(得分:0)
我不推荐该指南。我建议您查看本指南并对其进行调整以适合您的需求。 https://anidiots.guide/coding-guides/sqlite-based-points-system
此示例在用户每次发送任何消息时都进行计数,而是添加IF消息包含F-BOMB检查,然后添加点。