mirror of
https://github.com/ahmadk953/poixpixel-discord-bot.git
synced 2025-04-01 01:04:16 +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,
|
once: true,
|
||||||
execute: async (client: Client) => {
|
execute: async (client: Client) => {
|
||||||
const config = loadConfig();
|
const config = loadConfig();
|
||||||
const members = await client.guilds.cache
|
try {
|
||||||
.find((guild) => guild.id === config.guildId)
|
const guild = client.guilds.cache.find((guild) => guild.id === config.guildId);
|
||||||
?.members.fetch();
|
if (!guild) {
|
||||||
const nonBotMembers = members!.filter((m) => !m.user.bot);
|
console.error(`Guild with ID ${config.guildId} not found.`);
|
||||||
await setMembers(nonBotMembers);
|
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}`);
|
console.log(`Ready! Logged in as ${client.user?.tag}`);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue