add alerte perm admin add to user notification

This commit is contained in:
VALOU3336
2024-02-27 18:52:28 +01:00
parent ba5ff77610
commit df9eaeb581
4 changed files with 100 additions and 22 deletions
+40
View File
@@ -0,0 +1,40 @@
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('myDatabase.db');
module.exports = {
name: 'alerte',
description: 'Active ou désactive l\'alerte.',
category: 'gestion',
emote: '📢',
utilisation: '+alerte <on/off>',
async execute(message, args) {
if (!args.length) return message.reply('Veuillez spécifier "on" ou "off".');
const state = args[0].toLowerCase();
if (state !== 'on' && state !== 'off') {
return message.reply('Veuillez spécifier "on" ou "off".');
}
let data = await new Promise((resolve, reject) => {
db.get('SELECT value FROM gestion WHERE id = ?', [message.client.user.id], (err, row) => {
if (err) {
console.error(err.message);
reject(err);
}
resolve(row ? JSON.parse(row.value) : {});
});
});
if (!data[message.guild.id]) {
data[message.guild.id] = {};
}
data[message.guild.id].alerte = state;
db.run('INSERT OR REPLACE INTO gestion (id, value) VALUES (?, ?)', [message.client.user.id, JSON.stringify(data)], function(err) {
if (err) {
return console.error(err.message);
}
});
message.reply(`L'alerte a été ${state === 'on' ? 'activée' : 'désactivée'}.`);
},
};
+1 -1
View File
@@ -24,7 +24,7 @@ module.exports = {
if (!data[message.guild.id]) {
data[message.guild.id] = {};
}
data[message.guild.id].raidping = channelId;
data[message.guild.id].raidping = messageContent;
db.run('INSERT OR REPLACE INTO gestion (id, value) VALUES (?, ?)', [message.client.user.id, JSON.stringify(data)], function(err) {
if (err) {