-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsync-guides.js
More file actions
56 lines (46 loc) · 1.62 KB
/
sync-guides.js
File metadata and controls
56 lines (46 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env node
/**
* Standalone script for synchronizing guides to Discord channel
* Usage: npm run sync-guides [--initialize]
*/
import { Client, GatewayIntentBits } from 'discord.js';
import { config } from '../src/env.js';
import { syncGuidesToChannel, initializeGuidesChannel } from '../src/util/post-guides.js';
async function main() {
const args = process.argv.slice(2);
const shouldInitialize = args.includes('--initialize');
if (!config.guides.channelId) {
console.error('❌ GUIDES_CHANNEL_ID environment variable is required');
console.error('Please set it in your environment variables');
process.exit(1);
}
console.log(`🤖 Starting Discord client for guide sync...`);
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
],
});
try {
await client.login(config.discord.token);
console.log(`✅ Logged in as ${client.user?.tag}`);
if (shouldInitialize) {
console.log('🚀 Initializing guides channel (will post all guides fresh)...');
await initializeGuidesChannel(client, config.guides.channelId);
} else {
console.log('🔄 Synchronizing guides...');
await syncGuidesToChannel(client, config.guides.channelId);
}
console.log('✅ Guide synchronization completed successfully');
} catch (error) {
console.error('❌ Guide synchronization failed:', error);
process.exit(1);
} finally {
await client.destroy();
console.log('👋 Discord client disconnected');
}
}
main().catch((error) => {
console.error('❌ Unexpected error:', error);
process.exit(1);
});