-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
78 lines (73 loc) · 2.68 KB
/
bot.js
File metadata and controls
78 lines (73 loc) · 2.68 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const Discord = require("discord.js");
const client = new Discord.Client();
const auth = require("./auth.json");
var request = require('request');
var cheerio = require('cheerio');
const http = require('http');
const express = require('express');
const app = express();
app.get("/", (request, response) => {
console.log(Date.now() + " Ping Received");
response.sendStatus(200);
});
app.listen(process.env.PORT);
setInterval(() => {
http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);
client.on("ready", () => {
console.log("Logged in as Sugar!");
var dayMillseconds = 1000*60;
setInterval(function(){ // repeat this every 24 hours
sendMessage();
}, dayMillseconds);
});
function leftToEight(){
var d = new Date();
return (-d + d.setHours(8,0,0,0));
}
function sendMessage(){
request('https://www.celestialdn.net/', function(err, resp, body) {
if (err)
throw err;
$ = cheerio.load(body);
$('input').each(function() {
var url = ($(this).attr('value'));
if(String(url).indexOf('DAILY-') != -1){
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
if(today.getHours() == 7 && today.getMinutes() == 5){
today = mm + '/' + dd;
client.channels.find('name', 'daily-coupon').send(today);
client.channels.find('name', 'daily-coupon').send(String(url));
}
}
});
//console.log(body);
});
}
client.on('guildMemberAdd', member => {
// Send the message to a designated channel on a server:
const channel = member.guild.channels.find(ch => ch.name === 'runway');
// Do nothing if the channel wasn't found on this server
if (!channel) return;
// Send the message, mentioning the member
channel.send(String(member), { file: "https://cdn.discordapp.com/attachments/594358849830387732/601281587560316928/sugarguilddiscord.jpg" // Or replace with FileOptions object
});
});
client.on('message', msg => {
if (msg.content === '!ping') { //testing code with !ping
msg.channel.send('pong');
} else if (msg.content.split(" ")[0] === "!dice") { //Dice Roll with !dice (number of rolls)
var numTimes = msg.content.split(" ")[1];
if(isNaN(numTimes) || numTimes <=0) {msg.channel.send("Wrong format, use !dice 'number of rolls'"); return;}
var numList = []
for(var i = 0; i < numTimes; i++){
numList[i] = Math.floor(Math.random()*101);
}
console.log(numList);
msg.channel.send(String(numList));
}
});
client.login(auth.token);