Update src/events/ready.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Ahmad <103906421+ahmadk953@users.noreply.github.com>
This commit is contained in:
Ahmad 2025-03-01 00:52:12 -05:00 committed by GitHub
parent 7929354dde
commit 69ebfbd5b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,11 +9,19 @@ export default {
once: true,
execute: async (client: Client) => {
const config = loadConfig();
const members = await client.guilds.cache
.find((guild) => guild.id === config.guildId)
?.members.fetch();
const nonBotMembers = members!.filter((m) => !m.user.bot);
await setMembers(nonBotMembers);
try {
const guild = client.guilds.cache.find((guild) => guild.id === config.guildId);
if (!guild) {
console.error(`Guild with ID ${config.guildId} not found.`);
return;
}
const members = await guild.members.fetch();
const nonBotMembers = members.filter((m) => !m.user.bot);
await setMembers(nonBotMembers);
} catch (error) {
console.error('Failed to initialize members in database:', error);
}
console.log(`Ready! Logged in as ${client.user?.tag}`);
},