-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicds.net.ts
More file actions
128 lines (109 loc) · 4.38 KB
/
micds.net.ts
File metadata and controls
128 lines (109 loc) · 4.38 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
const Discord = require("discord.js");
const client = new Discord.Client();
/* Config import */
let config : any;
try {
config = require(__dirname + '/../config.json');
}
catch (Exception) {
throw new Error('Please create a config.json file!');
}
import { PingCommand } from './commands/ping';
import { Site } from './commands/site';
import { Channel } from './commands/channel';
import { Toggler } from './lib/toggler';
let site = new Site();
let channel = new Channel();
let typeAnnoy = false;
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('typingStart', (channel : any, user : any) => {
if (typeAnnoy) {
user.sendMessage("Typing Annoyer");
}
});
client.on('typingStop', (channel : any, user : any) => {
if (typeAnnoy) {
user.send("Typing Annoyer");
}
});
client.on('message', (msg : any) => {
switch (msg.content) {
case "/ping":
let ping = new PingCommand();
msg.reply(ping.ping());
break;
case "/checksite":
site.testSite().then(((res : any) => { msg.reply(res.toString()) })).catch((err : any) => { msg.reply(err.toString()) });
break;
case "/quote":
site.getQuote().then(((res : any) => { msg.reply(res.toString()) })).catch((err : any) => { msg.reply(err.toString()) });
break;
case "/lunch":
site.getLunch().then(((res : any) => { msg.reply(res.toString()) })).catch((err : any) => { msg.reply(err.toString()) });
break;
case "/break":
site.getDates().then(((res : any) => { msg.reply(res.toString()) })).catch((err : any) => { msg.reply(err.toString()) });
break;
case "/stats":
site.getStats().then(((res : any) => { msg.reply(res.toString()) })).catch((err : any) => { msg.reply(err.toString()) });
break;
case "/snowday":
site.getSnowdayChance().then(((res : any) => { msg.reply(res.toString()) })).catch((err : any) => { msg.reply(err.toString()) });
break;
case "/sports":
site.getSportsStats().then(((res : any) => { msg.reply(res.toString()) })).catch((err : any) => { msg.reply(err.toString()) });
break;
case "/note":
site.getNotification().then(((res : any) => { msg.reply(res.toString()) })).catch((err : any) => { msg.reply(err.toString()) });
break;
case "/weather":
site.getWeather().then(((res : any) => { msg.reply(res.toString()) })).catch((err : any) => { msg.reply(err.toString()) });
break;
case "/channel":
channel.formatChannelString(client.ping, client.status).then((result : any) => { msg.reply(result.toString()) }).catch((reject : any) => { msg.reply(reject.toString()) });
break;
case "/annoy":
typeAnnoy = Toggler.toggleBoolean(typeAnnoy);
msg.reply(`TypeAnnoy: ${typeAnnoy}`);
break;
case "/help":
const embed = new Discord.RichEmbed()
.setTitle("Commands Help")
.setAuthor("MyMICDS BOT", "https://mymicds.net/assets/logo/logo.svg")
/*
* Alternatively, use "#00AE86", [0, 174, 134] or an integer number.
*/
.setColor(0x42F4C2)
.setDescription("Hopefully this will help you navigate the bot")
.setFooter("This bot was created by Alex Migala using the Discord.js library | Powered by MyMICDS.net backend", "https://camo.githubusercontent.com/40129aa4640399b5e65cc3c101361a6a0b5d6467/68747470733a2f2f646973636f72642e6a732e6f72672f7374617469632f6c6f676f2e737667")
/*
* Takes a Date object, defaults to current date.
*/
.setTimestamp()
//.setURL("https://discord.js.org/#/docs/main/indev/class/RichEmbed")
.addField("Help",
"!help display help")
.addField("!checksite", "Checks to see if the MyMICDS.net site is online")
.addField("!quote", "Gets a random quote from our database")
.addField("!lunch", "Gets the lunch for today")
.addField("!break", "Gets the next long weekend")
.addField("!stats", "Gets the amount of people registered with the site")
.addField("!sports", "Gets the sports scores")
.addField("!channel", "Get stats on the channel")
// .addField("!note", "Gets the curent notification")
.addField("!weather", "Gets the current weather at MICDS")
/*
* Inline fields may not display as inline if the thumbnail and/or image is too big.
*/
//.addField("Inline Field", "They can also be inline.", true)
/*
* Blank field, useful to create some space.
*/
//.addBlankField(true)
//.addField("Inline Field 3", "You can have a maximum of 25 fields.", true);
msg.channel.send({embed});
}
});
client.login(config.clientToken);