mirror of
https://github.com/arthur-pbty/gestion-perso.git
synced 2026-06-14 08:08:18 +02:00
Mettre à jour les commandes ping et setprefix, ajouter la vérification des permissions, et initialiser la base de données.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
let buyer = 0;
|
||||
|
||||
module.exports = function addBaseInDB(client) {
|
||||
let db = new sqlite3.Database('db.db', sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE, (err) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
client.guilds.cache.forEach(guild => {
|
||||
db.run('INSERT OR IGNORE INTO prefix (serverID) VALUES (?)', [guild.id], (err) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
client.guilds.cache.forEach(guild => {
|
||||
guild.members.cache.forEach(member => {
|
||||
if (member.user.bot) return;
|
||||
if (member.id === '671763971803447298') {
|
||||
buyer = 1;
|
||||
} else {
|
||||
buyer = 0;
|
||||
};
|
||||
db.run('INSERT OR IGNORE INTO users (serverID, userID, buyer) SELECT ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM users WHERE serverID = ? AND userID = ?)', [guild.id, member.id, buyer, guild.id, member.id], (err) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
client.commands.forEach(command => {
|
||||
client.guilds.cache.forEach(guild => {
|
||||
db.run('INSERT OR IGNORE INTO commands (command, permission, serverID) SELECT ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM commands WHERE command = ? AND serverID = ?)', [command.name, command.permission, guild.id, command.name, guild.id], (err) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
db.close((err) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user