-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReminder.js
70 lines (62 loc) · 2.11 KB
/
Reminder.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
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
module.exports = class Reminder {
//Takes in time for alarm, userID that requested reminder, channelID it was requested in and text requested
//constructor(time, uid, chid, text, logger) {
constructor(type, variabler) { //Type er boolean, variabler er en array av variabler
if (type) {
var d = new Date();
this.time = ((variabler[0] * 60 * 1000) + (d.getTime())); //Gis minutter, gjør dette om til milisekunder og legger til nåværende tidspunkt
this.uid = variabler[1];
this.chid = variabler[2];
this.text = variabler[3];
variabler[4].info('P\u00e5minnelse opprettet');
} else {
this.time = variabler[0];
this.uid = variabler[1];
this.chid = variabler[2];
this.text = variabler[3];
}
}
get finishTime() {
return this.time;
}
get remainingTime() {
var result = this.time - new Date().getTime();
var respons = '';
var s = 0, m = 0, h = 0, d = 0, y = 0;
if (result >= 1000) {
s = (result - (result % 1000)) / 1000;
if (s >= 60) {
m = (s - (s % 60)) / 60;
s = s - (60 * m);
if (m >= 60) {
h = (m - (m % 60)) / 60;
m = m - (60 * h);
if (h >= 24) {
d = (h - (h % 24)) / 24;
h = h - (24 * d);
if (d >= 365) {
y = (d - (d % 365)) / 365;
d = d - (365 * y);
}
}
}
}
}
if (y > 0) { respons += y + ' år, '; }
if (d > 0) { respons += d + ' dager, '; }
if (h > 0) { respons += h + ' timer, '; }
if (m > 0) { respons += m + ' min, '; }
respons += s + ' sek.';
return respons;
return respons;
}
get channelID() {
return this.chid;
}
get userID() {
return this.uid;
}
get reqText() {
return this.text;
}
};