mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-12 15:56:25 +02:00
add : backup , antilick and event for antilink , wiki, and upgrade whitelist system with unique whitelist for guild
This commit is contained in:
@@ -11,6 +11,13 @@ module.exports = {
|
||||
}
|
||||
console.log('Connected to the SQLite database.');
|
||||
});
|
||||
const backupdb = new sqlite3.Database('backups.db', (err) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
}
|
||||
console.log('Connected to the backups database.');
|
||||
});
|
||||
|
||||
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
@@ -32,6 +39,20 @@ module.exports = {
|
||||
console.log('Table prevname created or already exists.');
|
||||
}
|
||||
});
|
||||
backupdb.run(`CREATE TABLE IF NOT EXISTS backups (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
botId TEXT NOT NULL,
|
||||
backupId TEXT NOT NULL,
|
||||
createdAt TEXT NOT NULL
|
||||
)`, (err) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
reject(err);
|
||||
} else {
|
||||
console.log('Table backups created or already exists.');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
db.get('SELECT value FROM gestion WHERE id = ?', [client.user.id], (err, row) => {
|
||||
if (err) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } = require('discord.js');
|
||||
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, ChannelType } = require('discord.js');
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
const { Events } = require("discord.js");
|
||||
const db = new sqlite3.Database('myDatabase.db');
|
||||
|
||||
const { getPermissionLevel } = require('../../fonction/getPermissionLevel');
|
||||
module.exports = {
|
||||
name: Events.MessageCreate,
|
||||
async execute(message) {
|
||||
async execute(message, client) {
|
||||
const botId = message.client.user.id;
|
||||
const guildId = message.guild.id;
|
||||
|
||||
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) {
|
||||
@@ -21,8 +21,14 @@ module.exports = {
|
||||
const suggestChannelId = data.suggestChannel && data.suggestChannel[guildId];
|
||||
data.piconly = data.piconly || {};
|
||||
data.piconly[guildId] = data.piconly[guildId] || {};
|
||||
const channelID = data.piconly[guildId];
|
||||
|
||||
const channelIDpiconly = data.piconly[guildId];
|
||||
const antilinkConfig = data[guildId]?.antilink;
|
||||
let status = 'off';
|
||||
let type = 'invite';
|
||||
|
||||
if (antilinkConfig) {
|
||||
({ status, type } = antilinkConfig);
|
||||
}
|
||||
if (message.channel.id === suggestChannelId && !message.author.bot) {
|
||||
await message.delete();
|
||||
|
||||
@@ -43,11 +49,41 @@ module.exports = {
|
||||
const suggestionMessage = await message.channel.send({ embeds: [embed], components: [row] });
|
||||
suggestionMessage.react('👎')
|
||||
suggestionMessage.react('👍')
|
||||
} else if (message.channel.id === channelID) {
|
||||
} else if (message.channel.id === channelIDpiconly) {
|
||||
if (message.attachments.size === 0) {
|
||||
message.delete()
|
||||
}
|
||||
|
||||
}
|
||||
} else if (status === 'on') {
|
||||
data.whitelist = data.whitelist || {};
|
||||
data.whitelist[guildId] = data.whitelist[guildId] || {};
|
||||
const whitelist = data.whitelist[guildId];
|
||||
const user = message.member;
|
||||
if (await getPermissionLevel(user, client) >= 10) return;
|
||||
if (whitelist[message.author.id]) return;
|
||||
const messageContent = message.content;
|
||||
if (type === 'all' && messageContent.includes('https://')) {
|
||||
message.delete().catch(err => {;
|
||||
});
|
||||
}
|
||||
if (type === 'invite' && (messageContent.includes('discord.com') || messageContent.includes('discord.gg'))) {
|
||||
message.delete().catch(err => {
|
||||
});
|
||||
}
|
||||
} else if (status === 'max') {
|
||||
if (message.channel.type === ChannelType.DM) return;
|
||||
const user = message.member;
|
||||
if (await getPermissionLevel(user, client) >= 10) return;
|
||||
|
||||
const messageContent = message.content;
|
||||
if (type === 'all' && messageContent.includes('https://')) {
|
||||
message.delete().catch(err => {;
|
||||
});
|
||||
}
|
||||
if (type === 'invite' && (messageContent.includes('discord.com') || messageContent.includes('discord.gg'))) {
|
||||
message.delete().catch(err => {
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user