add welcome message for new users in general chat upon joining
All checks were successful
CI / build (push) Successful in 9s
All checks were successful
CI / build (push) Successful in 9s
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Client, Events, GuildMember } from "discord.js";
|
import { Client, Events, GuildMember } from "discord.js";
|
||||||
import { db } from "../..";
|
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.
|
// 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> {
|
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!),
|
timestamp: new Date(member.joinedTimestamp!),
|
||||||
isBot: member.user.bot,
|
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.",
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user