-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
30 lines (25 loc) · 896 Bytes
/
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
// Discord, Moment & dotenv setup
const client = require('./src/discord-config')
const dotenv = require('dotenv')
dotenv.config()
const { TOKEN } = process.env
// Bot functions import
const checkForReminders = require('./src/functions/checkForReminders')
// const handleNewReminder = require('./src/functions/handleNewReminder')
const createNewReminder = require('./src/functions/createNewReminder')
// Confirm successful log in
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}`)
})
// Run checkForReminders every 60 seconds to scan DB for outstanding reminders
setInterval(checkForReminders, 10000)
// Parse reminder request, save to DB, DM confirmation to user
client.on('message', (msg) => {
createNewReminder(msg)
})
// Log bot into discord
client.login(TOKEN).then(() => {
console.log('We logged in bois')
}).catch(error => {
console.log(error)
})