This repository has been archived by the owner on May 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwerd.js
43 lines (36 loc) · 1.48 KB
/
werd.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
const Discord = require("discord.js");
const client = new Discord.Client();
const { prefix, token, mwkey } = require("./config.json");
// Login message
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!\n`);
});
// Commands
const roll = require('./commands/roll');
const word = require('./commands/word');
client.on("message", (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
const currentTime = new Date();
const defaultLog = `[${currentTime.toLocaleString()}] ${message.author.username} ${message.author}`;
if (command === "ping") {
console.log(`${defaultLog} pinged.`);
return message.reply("pong.");
} else if (command === "pong") {
console.log(`${defaultLog} ponged.`);
return message.reply("ping.");
} else if (command === "m" || command === "d") {
return word.word(defaultLog, message, mwkey, command, args);
} else if (command === "roll" || command === "r") {
return roll.roll(defaultLog, message, args);
} else if (command === "delete") {
// hidden purge
message.channel.bulkDelete(2)
.then(console.log(`${defaultLog} deleted the last message.`));
} else {
message.delete()
.then(console.log(`${defaultLog} deleted unknown command ${message.content}.`));
}
});
client.login(token);