mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-12 00:04:35 +02:00
add alerte perm admin add to user notification
This commit is contained in:
@@ -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'}.`);
|
||||
},
|
||||
};
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user