-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
27 lines (21 loc) · 767 Bytes
/
main.js
File metadata and controls
27 lines (21 loc) · 767 Bytes
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
const createBot = require('./bot.js')
const fs = require('node:fs/promises')
const path = require('node:path')
async function main () {
const absolutePath = path.resolve('config')
let optionsArray
try {
optionsArray = require(absolutePath)
} catch {
await fs.copyFile(path.join(__dirname, 'default.js'), 'config.js')
console.info('No config file was found, so a default one was created.')
optionsArray = require(absolutePath)
}
optionsArray.forEach((options, index) => {
const bot = createBot(options)
bot.on('connect', () => console.info(`Bot ${index} connected to ${options.host}`))
bot.on('login', () => console.info(`Bot ${index} logged in`))
bot.on('end', () => console.info(`Bot ${index} ended`))
})
}
main()