diff --git a/app/bot.js b/app/bot.js index 1c0e4f8..5596ce7 100644 --- a/app/bot.js +++ b/app/bot.js @@ -45,6 +45,28 @@ client.on(Events.GuildMemberAdd, member => { }); +client.on(Events.GuildMemberRemove, member => { + db.get( + "SELECT enabled, channel_id, message FROM goodbye_config WHERE guild_id = ?", + [member.guild.id], + (err, row) => { + if (err || !row || !row.enabled) return; + + let msg = row.message; + + msg = msg + .replace("{user}", member.user.username) + .replace("{server}", member.guild.name); + + const channel = member.guild.channels.cache.get(row.channel_id); + if (channel) { + channel.send(msg); + } + } + ); +}); + + client.login(process.env.BOT_TOKEN); module.exports = client; diff --git a/app/db.js b/app/db.js index ec961c2..9ba6d5e 100644 --- a/app/db.js +++ b/app/db.js @@ -10,13 +10,20 @@ const db = new sqlite3.Database( ); // Création de la table si elle n'existe pas -db.run(` +db.exec(` CREATE TABLE IF NOT EXISTS welcome_config ( guild_id TEXT PRIMARY KEY, channel_id TEXT, enabled INTEGER NOT NULL, message TEXT NOT NULL - ) + ); + + CREATE TABLE IF NOT EXISTS goodbye_config ( + guild_id TEXT PRIMARY KEY, + channel_id TEXT, + enabled INTEGER NOT NULL, + message TEXT NOT NULL + ); `); module.exports = db; diff --git a/app/public/welcome.html b/app/public/dashboard.html similarity index 96% rename from app/public/welcome.html rename to app/public/dashboard.html index ba85e79..3d19dea 100644 --- a/app/public/welcome.html +++ b/app/public/dashboard.html @@ -1,9 +1,13 @@ - Bienvenue + Tableau de bord + +

Chargement...

Avatar @@ -24,6 +28,7 @@ document.getElementById("greeting").textContent = "Utilisateur non connecté."; }); + // --- Affichage des guilds de l'utilisateur --- fetch("/api/guilds") .then(res => res.json()) @@ -51,6 +56,7 @@ document.getElementById("guilds-list").innerHTML = "
  • Impossible de récupérer les guilds.
  • "; }); + fetch("/invite-bot") .then(res => res.json()) .then(data => { diff --git a/app/public/guild.html b/app/public/guild.html index 24f9af4..dfd00b9 100644 --- a/app/public/guild.html +++ b/app/public/guild.html @@ -4,16 +4,20 @@ Dashboard du serveur + +

    Chargement...

    +
    -

    - -

    - -

    - Variables disponibles :