-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv2.js
More file actions
62 lines (51 loc) · 1.3 KB
/
v2.js
File metadata and controls
62 lines (51 loc) · 1.3 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
const Discord = require("discord.js");
const axios = require("axios");
const client = new Discord.Client();
const util = require("./utility.js");
const fs = require("fs");
const { token, prefix } = require("./config.json");
const p = prefix;
const cmd_dir = "./commands/"; // Commands
client.once('ready', () => {
console.info("Bot Ready!");
util.ready(client);
let files = fs.readdirSync(cmd_dir);
files.forEach(f => {
f = f.toLowerCase();
cmd(f);
let alias = req(f).alias;
if (util.isset(alias)) {
alias.forEach(alia => {
addAlia(alia, f);
});
}
});
});
client.login(token);
function cmd(path) {
let str = util.rmExt(path); // Remove File Extension, It's a Command
addAlia(str, path); // Remove Dupiclated Code
}
function addAlia(alia, path) {
let v = req(path);
addArg(p, alia, (msg, args) => v.cmd(msg, args, client));
}
function addArg(p, cmd, fx) {
client.on("message", msg => {
if (!msg.content.startsWith(p)) return;
const args = msg.content.slice(p.length).trim().split(' ');
const cmd1 = args.shift().toLowerCase();
if (cmd1 == cmd) {
fx(msg, args);
}
});
}
function joinReturnMessage(k, v) { addCmd(k, msg => { msg.channel.send(v); }); }
function req(e) {
return require(cmd_dir + e);
}
class Text {
constructor(text) {
this.text = text;
}
}