-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1337.js
89 lines (75 loc) · 2.18 KB
/
1337.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const {EventEmitter} = require('events')
let fs = require('fs')
class Client extends EventEmitter {
constructor(){
super();
this.files = {}
this.path = null
EventEmitter.call(this);
this.setMaxListeners(0);
}
get()
{
return this.files
}
has(command){
if(this.files[command]) return this.files[command]
return false
}
init(path,extension){
this.path = path
let fC = 0
fs.readdir(path, (err, allFiles) => {
allFiles.forEach(file => {
fC++
if (!file.endsWith(extension)) return
let cName = file.split(".")[0]
let props = require(path + file)
if (!props) {
if(fC == allFiles.length) this.emit('ready')
return
}
let obj = {}
let name = props.name
this.files[name] = props.run
if(fC == allFiles.length) this.emit('ready')
})
})
}
}
module.exports = Client
/*let files = {}
let fs = require('fs')
const {EventEmitter} = require('events')
const b1337 = new EventEmitter()
const has = (command)=>{
if(files[command]) return files[command]
return false
}
module.exports.commands= {
has: has,
all: files,
}
exports.hand = b1337;
exports.initCommands = (hName,path,extension) => {
let fC = 0
fs.readdir(path, (err, allFiles) => {
console.log(allFiles.length)
allFiles.forEach(file => {
fC++
if (!file.endsWith(extension)) return
let cName = file.split(".")[0]
let props = require(path + file)
if (!props.command) {
if(fC == allFiles.length) b1337.emit('ready')
console.log('asd')
return
}
let obj = {}
let name = props.command.name
files[hName] = {}
files[hName].ts ={ run: props.run }
if(fC == allFiles.length) b1337.emit('ready')
})
})
}*/