This repository has been archived by the owner on Aug 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
62 lines (53 loc) · 1.65 KB
/
app.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
//
// Project Constants
//
require ('dotenv').config();
const Discord = require('discord.js');
const fs = require('fs');
const client = new Discord.Client({ disableEveryone: true });
client.commands = new Discord.Collection();
require('./util/eventLoader.js')(client);
//
// File Constants
//
const package = require('./package.json');
const config = require('./config.json');
//
// Discord Commands & Integration
//
// Reads all commands & boot them in.
fs.readdir('./commands', (err, files) => {
if (err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === 'js')
if (jsfile.length <= 0) {
console.log('Couldn\'t find commands.');
return
}
jsfile.forEach((files, i) => {
let props = require(`./commands/${files}`);
console.log(`[CONSOLE] [DISCORD] ${files} has been loaded.`);
client.commands.set(props.help.name, props);
})
});
client.on("message", (message) => {
if (message.author.bot) return;
if (message.channel.type === "dm") return;
let prefix = process.env.discordprefix;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
if (!cmd.startsWith(prefix)) return;
let commandfile = client.commands.get(cmd.slice(prefix.length));
if (commandfile) commandfile.run(client, message, args);
});
//
// Application Boot
//
function applicationboot() {
console.log(`\n// ${package.name} v.${package.version}\nGitHub Repository: ${package.homepage}\nCreated By: ${package.author}`);
client.login(process.env.discordapitoken);
client.on("ready", () => {
console.log('[CONSOLE] [DISCORD] Discord bot has been deployed.');
});
};
applicationboot();