feat: pre-fetch guild members on boot
Node.js CI / CI (pull_request) Failing after 14s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 51s

This commit is contained in:
2026-03-24 20:20:21 -07:00
committed by Naomi Carrigan
parent 76e559876b
commit 679f46c967
2 changed files with 13 additions and 5 deletions
+10 -3
View File
@@ -20,6 +20,7 @@ import { softbanCommand } from "./commands/softban.js";
import { unbanCommand } from "./commands/unban.js"; import { unbanCommand } from "./commands/unban.js";
import { unmuteCommand } from "./commands/unmute.js"; import { unmuteCommand } from "./commands/unmute.js";
import { warnCommand } from "./commands/warn.js"; import { warnCommand } from "./commands/warn.js";
import { guildConfig } from "./config/guild.js";
// eslint-disable-next-line stylistic/max-len -- Import path cannot be shortened // eslint-disable-next-line stylistic/max-len -- Import path cannot be shortened
import { onGuildAuditLogEntryCreate } from "./events/guildAuditLogEntryCreate.js"; import { onGuildAuditLogEntryCreate } from "./events/guildAuditLogEntryCreate.js";
import { onGuildMemberAdd } from "./events/guildMemberAdd.js"; import { onGuildMemberAdd } from "./events/guildMemberAdd.js";
@@ -127,11 +128,17 @@ client.on(Events.GuildAuditLogEntryCreate, (entry, guild) => {
void onGuildAuditLogEntryCreate(entry, guild, client); void onGuildAuditLogEntryCreate(entry, guild, client);
}); });
client.on(Events.ClientReady, () => { client.on(Events.ClientReady, (readyClient) => {
void logger.log( void (async(): Promise<void> => {
const guild = readyClient.guilds.cache.get(guildConfig.guildId);
if (guild) {
await guild.members.fetch();
}
await logger.log(
"debug", "debug",
`Keiko is online as ${client.user?.username ?? "unknown"}.`, `Keiko is online as ${readyClient.user.username}.`,
); );
})();
}); });
await client.login(process.env.DISCORD_TOKEN); await client.login(process.env.DISCORD_TOKEN);
+1
View File
@@ -29,6 +29,7 @@ const commandData = [
const rest = new REST().setToken(process.env.DISCORD_TOKEN ?? ""); const rest = new REST().setToken(process.env.DISCORD_TOKEN ?? "");
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- REST returns unknown; shape is documented by Discord API */
const me = await rest.get(Routes.user()) as { id: string; username: string }; const me = await rest.get(Routes.user()) as { id: string; username: string };
console.log(`Authenticated as: ${me.username} (${me.id})`); console.log(`Authenticated as: ${me.username} (${me.id})`);