mirror of
https://github.com/ahmadk953/poixpixel-discord-bot.git
synced 2025-03-29 15:54:15 +00:00
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:
parent
7929354dde
commit
69ebfbd5b8
1 changed files with 13 additions and 5 deletions
|
@ -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}`);
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue