-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
32 lines (25 loc) · 875 Bytes
/
main.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
require('dotenv').config();
const Discord = require('discord.js');
const fetch = require("node-fetch");
const bot = new Discord.Client();
const TOKEN = process.env.TOKEN;
const config = require("./config.json");
const url = "https://get-lucky.netlify.com/.netlify/functions/get"
let date = new Date();
let hour = date.getHours();
bot.on('ready', () => {
console.info(`Logged in as ${bot.user.tag}!`);
});
bot.on('message', msg => {
bot.login(TOKEN);
fetch(url)
.then(res => res.json())
.then(r => {
var lucky = r.data
if (msg.content === '!lucky') {
var date = lucky.date.split(" ")
msg.channel.send(`Dzisiaj (${date[0]}) szczęśliwy numerek ma numer ${lucky.luckyNumber} - ${config[lucky.luckyNumber]}`);
}
})
});
bot.login(TOKEN);