Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (34 loc) · 1.69 KB
/
Copy pathindex.js
File metadata and controls
41 lines (34 loc) · 1.69 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
import { Client, GatewayIntentBits, Events } from 'discord.js'
import { repos, excludedRepos, allChannels, dryRun } from './stuff/config.js'
import { ctx } from './stuff/ctx.js'
import { loop } from './stuff/poll.js'
import { setupBugSync } from './stuff/bugsync.js'
import { settingsCommands } from './stuff/settings.js'
import { feedCommand, setupCommand, systemInfoCommand, handleCommand } from './stuff/commands.js'
import { startPanel } from './stuff/panel.js'
console.log(process.env.GITHUB_TOKEN ? 'github token loaded' : 'no github token, requests are anonymous')
console.log(repos.length ? `watching ${repos.join(', ')}` : 'no repos in config.json, nothing to watch')
if (excludedRepos.length) console.log(`excluding ${excludedRepos.join(', ')}`)
startPanel()
if (dryRun) {
loop()
} else {
const client = ctx.client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
sweepers: { threads: { interval: 0, lifetime: 0 } }
})
setupBugSync(client)
client.on(Events.InteractionCreate, handleCommand)
client.once(Events.ClientReady, async () => {
try {
const set = await client.application.commands.set([feedCommand, setupCommand, systemInfoCommand, ...settingsCommands])
console.log(`registered ${set.size} slash commands: ${set.map(command => command.name).join(', ')}`)
} catch (err) {
console.log(`registering slash commands failed: ${err.message}`)
console.log(JSON.stringify(err.rawError ?? err.requestBody ?? {}, null, 2))
}
console.log(`logged in as ${client.user.tag}, posting in ${allChannels().length} channel(s)`)
loop()
})
await client.login(process.env.DISCORD_TOKEN)
}