-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmds.js
35 lines (32 loc) · 823 Bytes
/
cmds.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
var fs = require( "fs" );
var bot = require( "./bot.js" );
var cmdFolder = "./cmds/";
LoadBotCommands = function() {
var files = fs.readdirSync( cmdFolder );
for ( f in files ) {
var file = files[ f ];
require( cmdFolder + file );
console.log( "Loaded Command File: " + file );
}
}
ReloadBotCommands = function() {
var files = fs.readdirSync( cmdFolder );
for ( cmd in bot.commands ) {
bot.unregisterCommand( cmd );
}
for ( f in files ) {
var file = files[ f ];
delete require.cache[ require.resolve( cmdFolder + file ) ];
try {
require( cmdFolder + file );
} catch( e ) {
console.log( "Could not require " + file );
console.log( e );
}
console.log( "Reloaded Command File: " + file );
}
}
module.exports = {
LoadBotCommands: LoadBotCommands,
ReloadBotCommands: ReloadBotCommands
}