mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
27 lines
942 B
JavaScript
27 lines
942 B
JavaScript
const sqlite3 = require('sqlite3').verbose();
|
|
const db = new sqlite3.Database('myDatabase.db');
|
|
const { Events } = require("discord.js");
|
|
module.exports = {
|
|
name: Events.MessageCreate,
|
|
async execute(message) {
|
|
if (message.author.bot) return;
|
|
db.get('SELECT value FROM gestion WHERE id = ?', [message.client.user.id], async (err, row) => {
|
|
if (err) {
|
|
console.error(err.message);
|
|
return;
|
|
}
|
|
|
|
const data = row ? JSON.parse(row.value) : {};
|
|
const guildData = data[message.guild.id];
|
|
|
|
if (guildData && guildData.autoreact && guildData.autoreact[message.channel.id]) {
|
|
const emojis = guildData.autoreact[message.channel.id];
|
|
|
|
try {
|
|
await Promise.all(emojis.map(emoji => message.react(emoji)));
|
|
} catch (error) {
|
|
}
|
|
}
|
|
});
|
|
},
|
|
}; |