-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
60 lines (54 loc) · 1.55 KB
/
index.js
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
57
58
59
60
import fs from 'fs'
import JiraApi from 'jira-client'
import {Client, Intents} from 'discord.js'
import {REST} from '@discordjs/rest'
import {Routes} from 'discord-api-types/v9'
const config = JSON.parse(fs.readFileSync('./config.json'))
const client = new Client({intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]})
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`)
// Set the presence for the bot (Listening to !help)
client.user.setPresence({
status: 'online',
activities: [{
name: config.prefix + 'help',
type: 'LISTENING'
}]
})
})
const jira = new JiraApi({
protocol: 'https',
host: config.host,
port: 443,
username: config.user,
password: config.password,
apiVersion: '2',
strictSSL: true
})
;(async () => {
const commands = []
for (const module of ['eigenbot', 'minecraft-version']) {
const m = await import('./' + module + '.js')
const moduleCommands = (await m.default(client, config, jira)) || []
for (const command of moduleCommands) {
if (command.toJSON) {
commands.push(command.toJSON())
} else {
commands.push(command)
}
}
}
if (!commands.length) return
const rest = new REST({version: '9'}).setToken(config.token)
client.on('ready', () => {
const clientId = client.application.id
rest.put(
config.guild
? Routes.applicationGuildCommands(clientId, config.guild)
: Routes.applicationCommands(clientId),
{body: commands}
)
})
// Login with token
client.login(config.token)
})()