-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
114 lines (83 loc) · 2.97 KB
/
index.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
require('discord-reply'); //⚠️ IMPORTANT: put this before your discord.Client()
var discord = require('discord.js')
var Collection = discord.Collection
const express = require("express")
const app = express()
app.use(express.json());
app.use(express.urlencoded());
// Optional events
const client = new discord.Client({ intents: [discord.Intents.FLAGS.GUILDS, discord.Intents.FLAGS.GUILD_MESSAGES] });
const { config } = require('dotenv');
const fs = require('fs');
const ascii = require('ascii-table');
const { readdirSync } = require('fs');
const mongoose = require('mongoose');
const admins = require('./models/admin')
var adminlist
var usrnames = []
async function getAdmins() {
var store = require("./models/admin.js")
var docs = await store.find({ });
var usrnames = []
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({limit: '5mb', extended: true}));
for (let index = 0; index < docs.length; index++) {
var usrelement = docs[index].name;
var levelelement = docs[index].level;
usrnames.push("<center> Username: " + usrelement + ", Level: " + levelelement)
}
var returnlist = await usrnames
adminlist = returnlist.join("</center> ")
}
getAdmins()
client.commands = new Collection();
client.aliases = new Collection();
client.queue = new Map();
const table = new ascii().setHeading('Command', 'Status');
client.loadedCommands = table
client.mongoose = require('./utils/mongoose');
readdirSync('./commands/').forEach(async dir => {
const commands = readdirSync(`./commands/${dir}/`).filter(f => f.endsWith('.js'));
for (let file of commands) {
let pull = require(`./commands/${dir}/${file}`);
if (pull.name) {
client.commands.set(pull.name, pull);
table.addRow('' + file, '✅ Loaded! ');
} else {
table.addRow('' + file, '❌ -> Command failed to load, please check your work again! ');
continue;
}
if (pull.aliases && Array.isArray(pull.aliases))
pull.aliases.forEach(alias => {
return client.aliases.set(alias, pull.name);
});
}
})
var rp = require("request-promise-core");
var bodyParser= require("body-parser");
client.categories = fs.readdirSync('./commands/');
config({
path: `${__dirname}/.env`
});
['command'].forEach(handler => {
require(`./handlers/${handler}`)(client);
});
fs.readdir('./events/', (err, files) => {
if (err) return console.error;
files.forEach(file => {
if (!file.endsWith('.js')) return;
const evt = require(`./events/${file}`);
let evtName = file.split('.')[0];
client.on(evtName, evt.bind(null, client));
})
});
client.on('rateLimit', console.log)
app.get("/", (req, res)=>{
res.send(table.toString())
})
app.post("/upvote", (req, res) => {
console.dir(req.body)
})
client.login(process.env.TOKEN)
client.mongoose.init();
app.listen(1234)