mirror of
https://github.com/arthur-pbty/LazyBot.git
synced 2026-06-09 09:01:52 +02:00
add guildMemberAdd config
This commit is contained in:
+22
-6
@@ -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);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user