add guildMemberAdd config

This commit is contained in:
Arthur Puechberty
2026-01-15 02:31:11 +01:00
parent 0a0c419c6b
commit 12fde58b93
9 changed files with 1571 additions and 374 deletions
+22 -6
View File
@@ -1,6 +1,8 @@
const loadSlashCommands = require('./slash_commands.js');
loadSlashCommands();
const db = require("./db");
const { Client, GatewayIntentBits, ActivityType, Events } = require("discord.js");
const client = new Client({ intents: Object.values(GatewayIntentBits) });
@@ -20,12 +22,26 @@ client.on(Events.InteractionCreate, async interaction => {
});
client.on(Events.MessageCreate, message => {
if (message.author.bot) return;
const config = global.guildConfigs?.[message.guild.id];
if (config?.autoMessage) {
message.channel.send(config.autoMessage);
}
client.on(Events.GuildMemberAdd, member => {
db.get(
"SELECT enabled, channel_id, message FROM welcome_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("{mention}", `<@${member.id}>`)
.replace("{server}", member.guild.name);
const channel = member.guild.channels.cache.get(row.channel_id);
if (channel) {
channel.send(msg);
}
}
);
});