add welcome message for new users in general chat upon joining
All checks were successful
CI / build (push) Successful in 9s

This commit is contained in:
Space-Banane
2026-02-22 16:57:02 +01:00
parent 05adc62b81
commit d3c15c526b

View File

@@ -1,5 +1,6 @@
import { Client, Events, GuildMember } from "discord.js";
import { db } from "../..";
import { CHANNELS } from "../../config";
// Adds a User to the database as they just joined the server. This is used for tracking purposes and to store user data in the future.
export default async function addUserToDB(client: Client): Promise<void> {
@@ -14,6 +15,20 @@ export default async function addUserToDB(client: Client): Promise<void> {
timestamp: new Date(member.joinedTimestamp!),
isBot: member.user.bot,
});
// Get general chat and welcome the user
const generalChat = member.guild.channels.cache.find(
(channel) => channel.id === CHANNELS.GENERAL,
);
if (generalChat?.isTextBased()) {
await generalChat.send(
`Welcome to the server, ${member.user}! Feel free to introduce yourself and check out the channels.`,
);
} else {
console.error(
"General chat channel not found or is not text-based.",
);
}
});
}