-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (28 loc) · 993 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
31
32
33
34
const d = require("discord.js");
const dotenv = require("dotenv");
const bot = new d.Client();
dotenv.config();
let serverTime = new Date();
let offset = 0;
let GMT = new Date();
function update() {
serverTime.setTime(GMT.getTime() + offset * 60000);
}
bot.on("message", async message => {
update()
GMT = new Date();
if (message.author.bot || message.channel.type == "dm") return;
const command = message.content.split(" ")[0].toLowerCase();
const args = message.content.split(" ").slice(1);
if (message.content == "^now") {
message.channel.send(serverTime.toUTCString().split(" ").slice(0, 5).join(" "));
} else if (command == "^set") {
if (message.member.hasPermission('ADMINISTRATOR')) {
offset = parseInt(args[0])
message.reply(`You have set the server time to GMT+${offset}mins.`)
} else {
message.reply(`Only admins can use this command.`)
}
}
});
bot.login(process.env.TOKEN);