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
53 lines
2.1 KiB
JavaScript
53 lines
2.1 KiB
JavaScript
const sqlite3 = require('sqlite3').verbose();
|
|
const { Events, ChannelType } = require("discord.js");
|
|
const db = new sqlite3.Database('myDatabase.db');
|
|
const { getPermissionLevel } = require('../../fonction/getPermissionLevel');
|
|
|
|
module.exports = {
|
|
name: Events.MessageCreate,
|
|
async execute(message, client) {
|
|
const botId = message.client.user.id;
|
|
const guildId = message.guild.id;
|
|
const user = message.member;
|
|
if (message.channel.type === ChannelType.DM) return;
|
|
|
|
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) : {});
|
|
});
|
|
});
|
|
|
|
const antimentionConfig = data[guildId]?.antimention;
|
|
let statusMention = 'off';
|
|
let mentionLimit = 0;
|
|
|
|
if (antimentionConfig) {
|
|
({ type: statusMention, nombre: mentionLimit } = antimentionConfig);
|
|
}
|
|
|
|
if (statusMention !== "off") {
|
|
const mentionCount = message.mentions.users.size;
|
|
if (mentionLimit === 0) return;
|
|
if (mentionCount > mentionLimit) {
|
|
if (statusMention === "wl" || statusMention === "whitelist") {
|
|
if (await getPermissionLevel(user, client) >= 10) return;
|
|
if (whitelist[message.author.id]) return;
|
|
message.delete().catch(err => {});
|
|
}else if (statusMention === "owner") {
|
|
const userlevelsawait = await getPermissionLevel(user, client)
|
|
if (userlevelsawait >= 10) return;
|
|
message.delete().catch(err => {});
|
|
}else if (statusMention === "buyer") {
|
|
if (await getPermissionLevel(user, client) === 11) return;
|
|
if (whitelist[message.author.id]) return;
|
|
message.delete().catch(err => {});
|
|
}
|
|
|
|
}
|
|
}
|
|
},
|
|
}; |