Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"formatter": {
"language_server": {
"name": "oxfmt"
}
}
}
2 changes: 1 addition & 1 deletion src/common/events/load-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const logger = createLogger('events');

export const loadEvents = (client: Client) => {
for (const event of events) {
logger.log(`Loading event: ${event.name}`);
logger.info(`Loading event: ${event.name}`);
client[event.once ? 'once' : 'on'](event.name, async (...args) => {
try {
await event.execute(...args);
Expand Down
2 changes: 1 addition & 1 deletion src/common/interactions/autocomplete-interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const autoCompleteInteractions = new Map<
export const registerAutocompleteInteraction = (
interaction: AutoCompleteSubmitInteraction
) => {
logger.log(
logger.info(
`Registering autocomplete interaction: ${interaction.commandName}`
);
autoCompleteInteractions.set(interaction.commandName, interaction);
Expand Down
2 changes: 1 addition & 1 deletion src/common/interactions/button-interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const buttonSubmitInteractions = new Map<
export const registerButtonSubmitInteraction = (
interaction: ButtonSubmitInteraction
) => {
logger.log(
logger.info(
`Registering button submit interaction: ${interaction.commandName}`
);
buttonSubmitInteractions.set(interaction.commandName, interaction);
Expand Down
2 changes: 1 addition & 1 deletion src/common/interactions/modal-interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const modalSubmitInteractions = new Map<
export const registerModalSubmitInteraction = (
interaction: ModalSubmitInteraction
) => {
logger.log(
logger.info(
`Registering modal submit interaction: ${interaction.commandName}`
);
modalSubmitInteractions.set(interaction.commandName, interaction);
Expand Down
2 changes: 1 addition & 1 deletion src/common/interactions/select-menu-interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const selectMenuSubmitInteractions = new Map<
export const registerSelectMenuSubmitInteraction = (
interaction: SelectMenuSubmitInteraction
) => {
logger.log(
logger.info(
`Registering select menu submit interaction: ${interaction.commandName}`
);
selectMenuSubmitInteractions.set(interaction.commandName, interaction);
Expand Down
6 changes: 3 additions & 3 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export const config = {

export type Config = typeof config;

logger.log('✅ Configuration loaded successfully');
logger.log(
logger.info('✅ Configuration loaded successfully');
logger.info(
`📋 Client ID: ${config.discord.clientId ? config.discord.clientId : '❌ missing'}`
);
logger.log(
logger.info(
`🔑 Token: ${config.discord.token ? '***configured***' : '❌ missing'}`
);
2 changes: 1 addition & 1 deletion src/features/docs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const executeDocCommand = async (
},
});
} else if (componentInteraction.isButton()) {
logger.log('Documentation command cancelled by user.');
logger.info('Documentation command cancelled by user.');
await interaction.deleteReply();
}
});
Expand Down
10 changes: 5 additions & 5 deletions src/features/interaction-create/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const interactionCreateEvent = createEvent(
},
async (interaction) => {
if (!interaction.guildId || !isAllowedServer(interaction.guildId)) {
logger.log(
logger.info(
`⚠️ Command blocked from unauthorized server: ${interaction.guildId}`
);
if (interaction.isRepliable()) {
Expand All @@ -28,31 +28,31 @@ export const interactionCreateEvent = createEvent(
return;
}
if (interaction.isButton()) {
logger.log(
logger.info(
`Received button interaction with custom ID: ${interaction.customId}`
);
await handleButtonInteraction(interaction);
return;
}

if (interaction.isModalSubmit()) {
logger.log(
logger.info(
`Received modal submit interaction with custom ID: ${interaction.customId}`
);
await handleModalInteraction(interaction);
return;
}

if (interaction.isStringSelectMenu()) {
logger.log(
logger.info(
`Received select menu interaction with custom ID: ${interaction.customId}`
);
await handleSelectMenuInteraction(interaction);
return;
}

if (interaction.isAutocomplete()) {
logger.log(
logger.info(
`Received autocomplete interaction with custom ID: ${interaction.commandName}`
);
await handleAutoCompleteInteraction(interaction);
Expand Down
6 changes: 3 additions & 3 deletions src/features/ready/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export const readyEvent = createEvent(
once: true,
},
async (client) => {
logger.log(`Ready! Logged in as ${client.user.tag}`);
logger.info(`Ready! Logged in as ${client.user.tag}`);

// Check all guilds and leave any unauthorized ones
logger.log(`🔍 Checking ${client.guilds.cache.size} guild(s)...`);
logger.info(`🔍 Checking ${client.guilds.cache.size} guild(s)...`);
for (const guild of client.guilds.cache.values()) {
await leaveIfNotAllowedServer(guild);
}
Expand All @@ -47,7 +47,7 @@ export const readyEvent = createEvent(
}
// Sync guides to channel
try {
guidesLogger.log(
guidesLogger.info(
`🔄 Starting guide sync to channel ${config.channelIds.guides}...`
);
await syncGuidesToChannel(client, config.channelIds.guides);
Expand Down
4 changes: 2 additions & 2 deletions src/features/showcase-digest/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const processShowcaseDigestResults = async (
ageMs >= RESULTS_AFTER_DAYS * DAY &&
ageMs < (RESULTS_AFTER_DAYS + 1) * DAY;
if (!isDue) {
logger.log(
logger.info(
'Most recent showcase digest is not within the results window, skipping.'
);
return;
Expand All @@ -148,7 +148,7 @@ export const processShowcaseDigestResults = async (
message.createdTimestamp > digestMessage.createdTimestamp
);
if (alreadyAnnounced) {
logger.log('Showcase digest results have already been announced.');
logger.info('Showcase digest results have already been announced.');
return;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/features/showcase-digest/triggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ const SHOWCASE_DIGEST_CRONS = ['0 16 * * 5#1', '0 16 * * 5#3'];
const SHOWCASE_DIGEST_RESULTS_CRON = '0 16 * * 1';

const runScheduledShowcaseDigest = async (): Promise<void> => {
logger.log('Running scheduled showcase digest...');
logger.info('Running scheduled showcase digest...');
try {
await createShowcaseDigest();
logger.log(`Successfully displayed showcase digest!`);
logger.info(`Successfully displayed showcase digest!`);
} catch (error) {
logger.error(error);
}
};

const runScheduledShowcaseDigestResults = async (): Promise<void> => {
logger.log('Running scheduled showcase digest results...');
logger.info('Running scheduled showcase digest results...');
try {
await processShowcaseDigestResults();
} catch (error) {
Expand All @@ -55,7 +55,7 @@ const runScheduledShowcaseDigestResults = async (): Promise<void> => {
};

export function initializeShowcaseDigestScheduler(): void {
logger.log('Initializing showcase digest scheduler...');
logger.info('Initializing showcase digest scheduler...');

SHOWCASE_DIGEST_CRONS.forEach((expression) => {
cron.schedule(expression, runScheduledShowcaseDigest, { timezone: 'UTC' });
Expand All @@ -67,7 +67,7 @@ export function initializeShowcaseDigestScheduler(): void {
{ timezone: 'UTC' }
);

logger.log(
logger.info(
'Showcase digest scheduler initialized (digests on 1st and 3rd Fridays at 16:00 UTC, results on Mondays at 16:00 UTC)'
);
}
4 changes: 2 additions & 2 deletions src/loadEnvFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ function loadEnvFile(filePath: string) {
}
}
}
logger.log(`✅ Loaded: ${filePath}`);
logger.info(`✅ Loaded: ${filePath}`);
} catch (error) {
logger.warn(`Warning: Could not load ${filePath}`);
logger.warn(error);
}
}

const nodeEnv = process.env.NODE_ENV || 'development';
logger.log(`🌍 Environment: ${nodeEnv}`);
logger.info(`🌍 Environment: ${nodeEnv}`);

const ENV_FILES = {
test: join(process.cwd(), '.env.test'),
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/deploy-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createLogger } from '@/util/logger.js';
const logger = createLogger('deploy-commands');

export async function deployCommands() {
logger.log('Deploying commands...');
logger.info('Deploying commands...');
const commandData = [...commands.values()].map((command) => command.data);

const rest = new REST({ version: '10' }).setToken(config.discord.token);
Expand All @@ -26,7 +26,7 @@ export async function deployCommands() {
body: commandData,
}
)) as RESTPutAPIApplicationCommandsResult;
logger.log(
logger.info(
`✅ Successfully deployed ${result.length} commands to guild ${config.discord.serverId}`
);
} catch (error) {
Expand Down
12 changes: 6 additions & 6 deletions src/scripts/sync-guides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,33 @@ async function main() {
process.exit(1);
}

logger.log(`🤖 Starting Discord client for guide sync...`);
logger.info(`🤖 Starting Discord client for guide sync...`);

const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
});

try {
await client.login(config.discord.token);
logger.log(`✅ Logged in as ${client.user?.tag}`);
logger.info(`✅ Logged in as ${client.user?.tag}`);

if (shouldInitialize) {
logger.log(
logger.info(
'🚀 Initializing guides channel (will post all guides fresh)...'
);
await initializeGuidesChannel(client, config.channelIds.guides);
} else {
logger.log('🔄 Synchronizing guides...');
logger.info('🔄 Synchronizing guides...');
await syncGuidesToChannel(client, config.channelIds.guides);
}

logger.log('✅ Guide synchronization completed successfully');
logger.info('✅ Guide synchronization completed successfully');
} catch (error) {
logger.error('❌ Guide synchronization failed:', error);
process.exit(1);
} finally {
await client.destroy();
logger.log('👋 Discord client disconnected');
logger.info('👋 Discord client disconnected');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const UserBotMessagesService = {
where: { expiresAt: { lte: new Date() } },
});
if (count > 0) {
logger.log(`Cleaned up ${count} expired user bot messages.`);
logger.info(`Cleaned up ${count} expired user bot messages.`);
}
};

Expand Down
10 changes: 5 additions & 5 deletions src/util/advent-scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function createAdventPost(
},
});

logger.log(`✅ Created Advent of Code post: ${title}`);
logger.info(`✅ Created Advent of Code post: ${title}`);
return true;
} catch (error) {
logger.error(
Expand Down Expand Up @@ -109,7 +109,7 @@ async function checkAndCreateTodaysPost(

const alreadyPosted = await isDayPosted(year, day);
if (alreadyPosted) {
logger.log(`ℹ️ Advent of Code post for ${year} day ${day} already exists`);
logger.info(`ℹ️ Advent of Code post for ${year} day ${day} already exists`);
return;
}

Expand All @@ -128,7 +128,7 @@ export function initializeAdventScheduler(
client: Client,
channelId: string
): void {
logger.log('🎄 Initializing Advent of Code scheduler...');
logger.info('🎄 Initializing Advent of Code scheduler...');

checkAndCreateTodaysPost(client, channelId).catch((error) => {
logger.error(
Expand All @@ -140,13 +140,13 @@ export function initializeAdventScheduler(
// Schedule to run every day at midnight UTC-5
// https://github.com/node-cron/node-cron?tab=readme-ov-file#cron-syntax
cron.schedule('0 5 * * *', () => {
logger.log('⏰ Running scheduled Advent of Code check...');
logger.info('⏰ Running scheduled Advent of Code check...');
checkAndCreateTodaysPost(client, channelId).catch((error) => {
logger.error('❌ Error in scheduled Advent of Code check:', error);
});
});

logger.log(
logger.info(
'✅ Advent of Code scheduler initialized (runs daily at midnight UTC)'
);
}
2 changes: 1 addition & 1 deletion src/util/cache/recent-message-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class MessageCache {

// Bulk delete old messages
if (messagesToDelete.length > 0) {
logger.log(
logger.info(
`Cleaning up ${messagesToDelete.length} old messages from cache (older than ${maxRuleTimeframe}ms)`
);
this.bulkDeleteByIds(messagesToDelete);
Expand Down
2 changes: 1 addition & 1 deletion src/util/channel-prefetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const fetchAndCachePublicChannelsMessages = async (
const messages = await channel.messages.fetch({
limit: PER_CHANNEL_CACHE_LIMIT,
});
logger.log(
logger.info(
`Fetched and cached ${messages.size} messages from channel ${channel.name} (${channel.id})`
);
cachedChannelsMap.add(channel.id);
Expand Down
Loading
Loading