mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-16 15:56:31 +02:00
grand commit que tutur attend ( marche pas le raidmode en dev)
sinon il y a pleins de truc comme les anti raid , des coorectif ect
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
const db = new sqlite3.Database('myDatabase.db');
|
||||
|
||||
module.exports = {
|
||||
name: 'creationlimit',
|
||||
description: 'Définit une limite de création de salon après un certain nombre de jours.',
|
||||
utilisation: 'creationlimit off/10d',
|
||||
category: 'antiraid',
|
||||
emote: '🔗',
|
||||
async execute(message, args, client) {
|
||||
const botId = client.user.id;
|
||||
const guildId = message.guild.id;
|
||||
const limit = args[0];
|
||||
|
||||
if (!limit || (limit !== 'off' && !limit.match(/^\d+(m|h|d|w)$/))) {
|
||||
return message.reply('Veuillez utiliser la commande correctement: `+creationlimit off/temps`.');
|
||||
}
|
||||
|
||||
let data = await new Promise((resolve, reject) => {
|
||||
db.get('SELECT value FROM gestion WHERE id = ?', [botId], (err, row) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
reject(err);
|
||||
}
|
||||
resolve(row ? JSON.parse(row.value) : {});
|
||||
});
|
||||
});
|
||||
|
||||
if (!data[guildId]) {
|
||||
data[guildId] = {};
|
||||
}
|
||||
|
||||
if (limit === 'off') {
|
||||
data[guildId].creationLimit = null;
|
||||
} else {
|
||||
data[guildId].creationLimit = limit;
|
||||
}
|
||||
|
||||
db.run('INSERT OR REPLACE INTO gestion (id, value) VALUES (?, ?)', [botId, JSON.stringify(data)], function(err) {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
return message.reply('Une erreur est survenue lors de la mise à jour de la configuration.');
|
||||
}
|
||||
message.reply(`La limite de création de compte a été ${limit === 'off' ? 'désactivée' : `fixée à ${limit}`}.`);
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user