mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
9bd39c69ca
sinon il y a pleins de truc comme les anti raid , des coorectif ect
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
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}`}.`);
|
|
});
|
|
},
|
|
}; |